Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. var mongoClient = require('mongodb').MongoClient;
  2. mongoClient.connect('mongodb://localhost:27017/tut3', function (err, db) {
  3. if (err)throw err;
  4.  
  5. var collection = db.collection('messages');
  6. var cursor = collection.find({}, {_id : true}, {limit : 50});
  7. cursor.count(function (err, doc) {
  8. console.log("---- CURSOR ----")
  9. console.dir(doc); // 120477
  10.  
  11. cursor.each(function(err,doc){
  12. if(doc ==null){
  13. db.close()
  14. }
  15. console.dir(doc); //50
  16.  
  17. });
  18.  
  19. });
  20.  
  21.  
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement