我尝试一个接一个地获取两个文档。出于测试目的,我将 batchSize 设置为 1。而且我无法获取第二份文件。但是,当我将 batchSize 设置为 2 时,它会毫无问题地返回第二个文档。
mongoClient.connect('mongodb://127.0.0.1:27017/mydb?w=1&journal=true&wtimeout=4000',server:{auto_reconnect:true, poolSize:2}}, function(err, db){
var cursor = db.collection('coll').find({},{},{batchSize:1});
cursor.nextObject(function(e, doc)
{
console.log(doc);
//We successfully fetched the first document and now it's time to get the second one
cursor.nextObject(function(e, doc2)
{
//It returns NULL!
console.log(doc2);
});
});
});