MongoX 是 Perl 语言用来操作 MongoDB 数据库的开发包。
use MongoX host => ‘mongodb://127.0.0.1′,db => ‘test’;
use MongoX;
add_connection host => ‘127.0.0.1′;
use_connection;
use_db ‘test’;
add_connection host => ‘192.168.1.1′,id => ‘remote2′;
use_connection ‘remote2′;
my $foo = get_collection ‘foo’;
use_collection ‘foo’;
say ‘total rows:’,context_collection->count();
my $id = context_collection->insert({ name => ‘Pan’, home => ‘Beijing’ });
my $gridfs = context_db->get_gridfs;