Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoClient = require('mongodb').MongoClient;
- mongoClient.connect('mongodb://localhost:27017/tut3', function (err, db) {
- if (err)throw err;
- var collection = db.collection('messages');
- var cursor = collection.find({}, {_id : true}, {limit : 50});
- cursor.count(function (err, doc) {
- console.log("---- CURSOR ----")
- console.dir(doc); // 120477
- cursor.each(function(err,doc){
- if(doc ==null){
- db.close()
- }
- console.dir(doc); //50
- });
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement