I was trying to revamp an old Nodejs web service to replace callback functions with chained promises. When querying mongodb we used the syntax below to iterate through a result set.
collection.find(filter).toArray(function(err, items) {
if (err) {
throw(err);
} else {
console.log(items);
}
If I try to replace the .toArray() section with a .then() I get the below error "col.find(...).then is not a function".
If I replace .find() with .findOne().then(), the code works perfectly.
Any help is appreciated.