0

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);
Community
  • 1
  • 1
kpce
  • 35
  • 9

0 Answers0