BUS-MONGO is a mongodb client, it is more easy-to-use than mongodb-native, and more flexable than mongoose.
$ npm install bus-mongo
current stable branch is master.
firstly ,we need to connect mongodb with the url.
var bus_mongo = require('bus-mongo');
var my_db = bus_mongo.init('mongodb://username:password@localhost:port/my_db');
if you have replicated sets, just add in url
var bus_mongo = require('bus-mongo');
var my_db = bus_mongo.init('mongodb://username:password@master-server:port, mongodb://username:password@slave-server:port/my-db-name');
we can access the other db object after connect to the admin db of mongo
var my_db = bus_mongo.db('my-db-name');
we can access the collection of the db object.
var my_collection = my_db.collection('collection-name');
we can do all the crud operations of the collection, for example:
my_collection.insert({test:1}, function(err){
if(err) console.log(err);
else console.log('success insert!');
});
more operations's docs in here