‚̧Neurotoxin Powered Marketing
    Have ideas to improve npm?Join in the discussion! ¬Ľ

    co-monk

    1.0.0¬†‚Äʬ†Public¬†‚Äʬ†Published

    co-monk

    MongoDB with generator goodness.

    Installation

    $ npm install co-monk
    

    Setup

    Call wrap() on collections to make them generator friendly:

    var monk = require('monk');
    var wrap = require('co-monk');
    var db = monk('localhost/test');
     
    var users = wrap(db.get('users'));

    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

    Install

    npm i co-monk

    DownloadsWeekly Downloads

    441

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar