Nedb made more awesome with generators.
$ npm install co-nedb
Call wrap()
on collections to make them generator friendly:
var Datastore = require('nedb');
var wrap = require('co-nedb');
var db = new Datastore({ autoload: true }); // in-memory database
var users = wrap(db);
Simple example:
yield users.remove({});
yield users.insert({ name: 'Tobi', species: 'ferret' });
yield users.insert({ name: 'Loki', species: 'ferret' });
yield users.insert({ name: 'Jane', species: 'ferret' });
var res = yield users.findOne({ name: 'Tobi' });
res.name.should.equal('Tobi');
var res = yield users.find({ species: 'ferret' });
res.should.have.length(3);
Parallel inserts:
yield users.remove({});
yield [
users.insert({ name: 'Tobi', species: 'ferret' }),
users.insert({ name: 'Loki', species: 'ferret' }),
users.insert({ name: 'Jane', species: 'ferret' })
];
var res = yield users.findOne({ name: 'Tobi' });
res.name.should.equal('Tobi');
var res = yield users.find({ species: 'ferret' });
res.should.have.length(3);
MIT
- Bumped thunkify version from
0.0.1
to2.1.2
. - Removed nedb as a dependency
- Added .npmignore