basicmongo
v2.0.3
Published
Easy way to use mongodb.
Downloads
8
Readme
WHAT'S NICE ABOUT THIS MODULES?
- Offer an easier way to access mongodb, no more callbacks after callbacks.
- In each instance commands will be run by sequnce, you don't have to worry about those "find" command run before "update" command situations anymore.
HOW TO USE?
Quick Start
const BasicMongo = require('basicmongo');
const mongo = BasicMongo.create(
'%YOUR HOST%',
%YOUR PORT%,
'%YOUR DATABASE%',
%DEBUG OR NOT%);
mongo
.run( (db, resolve, reject) => {
db.collection('test')
.find({})
.toArray(
(err, result) => {
console.log(result);
resolve(result);
}
)
} )
.get( (result, resolve) => {
console.log(result);
resolve();
} );
Or You Can Use EasyMongo Methods
mongo
.collection('test')
.find({})
.get( (data, resolve) => {
console.log(data);
resolve();
} )
.insert({ title: 'test' })
.find({})
.get( (data, resolve) => {
console.log(data);
resolve();
} )
.remove({ title: 'test' })
.find({})
.get( (data, resolve) => {
console.log(data);
resolve();
} );
Method List
Basic Methods
- run (runCommandFunc)
- runCommandFunc (db, resolve, reject)
- get (getCommandFunc)
- getCommandFunc (result, resolve, reject)
EasyMongo Methods
- insert (docs, options)
- remove (selector, options)
- update (selector, doc, options)
- default options = { upsert : true, multi : true }
- find (query, options) // You should use get method to get result.
- rename (newName, options)
- aggregate (pipeline, options) // You should use get method to get result.
CONTACT ME
Email: [email protected]