Skip to content

wyTrivail/bus-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUS-MONGO

BUS-MONGO is a mongodb client, it is more easy-to-use than mongodb-native, and more flexable than mongoose.

Documentation

BUS-MONGO documents

Installation

$ npm install bus-mongo

Stability

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

Releases

No releases published

Packages

No packages published