cofy-mongodb

0.0.1 • Public • Published

cofy-mongodb

Build Status

co version node-mongodb-native.

Installation

$ npm install cofy-mongodb --save

Old methods not change.New methods invoke convention: yield obj.$asyncMethod

Example:

var mongodb = require('cofy-mongodb');
var MongoClient = mongodb.MongoClient;
var co = require('co');
 
co(function*(){
    var db = yield MongoClient.$connect('mongodb://localhost:27017/test');
    var collection = db.collection('test_users');
    var tom = {name:"tom",age:10};
    var tom1 = yield collection.$insert(tom);
    var tom2 = yield collection.find({name:"tom"}).sort('name').limit(1).$toArray();
    console.log(tom , tom1, tom2);
    yield collection.$remove({name:"tom"});
    db.close();
    tom1[0]._id.should.be.ok;
    tom2[0]._id.should.be.ok;
    tom2[0].should.eql(tom);
});

Package Sidebar

Install

npm i cofy-mongodb

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • rocksonzeta