Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Q = require('q');
- var mongo = require('mongodb'),
- Server = mongo.Server,
- Db = mongo.Db;
- var server = new Server('localhost', 27017, {auto_reconnect: true});
- var db_ = new Db('annotedw', server, {safe: true});
- Q.ncall(db_.open, db_).then(
- function(db) {
- return Q.ncall(db.collection, db, 'corpus');
- }
- )
- .then(
- function(coll) {
- var cursor = coll.find();
- return cursor;
- }
- )
- .then(function(cursor) {
- cursor.each(function(err, item) {
- if(item != null) {
- console.log(item.name);
- } else {
- db_.close();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement