Skip to content
/ co-nedb Public
forked from tj/co-monk

Nedb made more awesome with generators

Notifications You must be signed in to change notification settings

jksdua/co-nedb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-nedb NPM version Dependencies Status Build Status

Nedb made more awesome with generators.

Installation

$ npm install co-nedb

Setup

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);

Example

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);

License

MIT

Changelog

v2.0.0 (18 Oct 2014)

  • Bumped thunkify version from 0.0.1 to 2.1.2.
  • Removed nedb as a dependency
  • Added .npmignore

About

Nedb made more awesome with generators

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%