npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

comongo

0.0.5 • Public • Published

co-mongo

mongo coroutine library based on co and node-mongodb-native

Installation

$ npm install comongo

Usage

var mongo = require('comongo');
var db = yield mongo.connect('localhost/test');
var coll = db.collection('your coll name');
 
// insert
var ret = yield coll.insert({ hello: 'world' });
 
// cursor and query
var cur = coll.find({ hello: 'world' }).skip(0);
 
// toArray and foreach
(yield cur.toArray()).forEach(function(item) {
  // sync foreach, don't need care about async call
});
 
// Error handler
try {
  // your co-mongo codes
} catch (err) {
  // handles error from err
}

License

MIT

Keywords

install

npm i comongo

Downloadsweekly downloads

10

version

0.0.5

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability