mongodb-client
v0.0.1
Published
A nice API client for MongoDB.
Downloads
103
Readme
mongodb-client
A nice API client for MongoDB.
Features
- Make API as same as MongoDB CRUD Reference
- Reading the source codes just like reading the document of MongoDB client.
- Fix native mongodb
insertedIds
data format error onoptions.ordered = false
. - Remove
insert()
method, please use the more clearinsertMany()
andinsertOne()
instead. - Disable
options.forceServerObjectId
on write methods. - ...
Installation
$ npm install mongodb-client
Quick start
const co = require('co');
const MongoDB = require('mongodb-client');
const db = new MongoDB('mongodb://localhost:27017/myproject');
// listen db connect error event
db.on('error', err => {
console.error(err);
});
// wait for db connected
db.ready(() => {
// let's read and write
co(function*() {
const result = yield db.collection('user').insertMany([
{ name: 'fengmk2', type: 'JavaScript' },
{ name: 'dead-horse', type: 'JavaScript' },
{ name: 'tj', type: 'go' },
]);
console.log(result);
const docs = yield db.collection('user').find({ type: 'JavaScript' }).skip(10).toArray();
console.log(docs);
}).catch(err => {
console.error(err);
console.error(err.stack);
});
});
License
APIs
CURD
Insert Documents
TBD
Modify Documents
TBD
Query Documents
TBD
Remove Documents
Indexes
TBD
Aggregation
TBD
Administration
TBD