0
하나씩 두 개의 문서를 가져 오려고합니다. 테스트 목적으로 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);
});
});
});
방금 toArray()와 동일하게 시도했지만 단 하나의 문서도 반환했습니다. 아마 나 한테 뭔가 잘못 됐을거야? –