Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    co-nedbpublic

    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

    install

    npm i co-nedb

    Downloadsweekly downloads

    8

    version

    2.0.1

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar