bus-mongo
v1.0.23
Published
a flexible mongodb client
Readme
BUS-MONGO
BUS-MONGO is a mongodb client, it is more easy-to-use than mongodb-native, and more flexable than mongoose.
Documentation
Installation
$ npm install bus-mongoStability
current stable branch is master.
Overview
init
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');get db
we can access the other db object after connect to the admin db of mongo
var my_db = bus_mongo.db('my-db-name');get collection
we can access the collection of the db object.
var my_collection = my_db.collection('collection-name');crud
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
