thunkify-mongodb
Installation | Examples | Supported MongoDB versions | Roadmap | Under the hood | Running tests | License
Give MongoDB native driver 2.0 a sweet generator aftertaste 🍭
Wrapper on MongoDB native driver to provide thunk methods, useful for generator-based flow control such as co, Koa, etc.
Installation
$ npm install thunkify-mongodb --save
Examples
Basic | Events | Bulk Operations
Basic
var MongoClient = MongoClient;var mongodb = ; { var mongoClient = ; var db = mongoClient; var collection = db; collection; db;}
Events
All EventEmitter methods are wrapped.
You can use on
and once
methods as generators:
db;
You can also use them with a callback:
db;
Bulk Operations
var MongoClient = MongoClient;var mongodb = ; { var mongoClient = ; var db = mongoClient; var collection = db; var batch = collection; batch; batch; batch; batch; batch; // Execute the operations var result = batch; db; return result;}
Supported MongoDB versions
- All 2.X.X versions of MongoDB Native Driver are supported.
Roadmap
AggregationCursor, GridStore, Mongos, etc. coming soon. Feel free to PR.
Under the hood
thunkify-object is used as a thunk wrapper engine.
Running tests
You need a running MongoDB instance on mongodb://localhost:27017/thunkify-mongodb-test
to run all the tests.
$ make test
With code coverage.
$ make test-cov
License
Thunkify-mongodb is freely distributable under the terms of the MIT license.