mongodb force同步查找文件

时间:2013-11-20 22:42:39

标签: mongodb

有没有办法为mongo查询创建同步find()?

像:

var MongoClient = require('mongodb').MongoClient;

MongoClient.connect('mongodb://localhost:27017/mydb', function(err, db){

  if(err) throw err;

  var collection = db.collection('mycollection');

  var myarray  = collection.find({});

  //use myarray
  for (var i = myarray.length - 1; i >= 0; i--) {
    console.log(myarray[i]);
  };

});

0 个答案:

没有答案