samedi 28 février 2015

Cursor.find returns undefined, MongoDB [duplicate]


I am trying to convert my find cursor object into an array using the toArray() function. I have been having trouble understanding the callback required in this function and have tried implementing it in the following way but it returns undefined. Any help on how to use the toArray() method is much appreciated



var collection = db.collection('notes');
var find = collection.find(cr);
var findArray = [];
findArray = find.toArray(function(err, items){
findArray = items;});
console.log("Found: ");
console.log(findArray);




Aucun commentaire:

Enregistrer un commentaire