I’m confused by what exactly the done
function is in this example (mongoose/mongodb). From my understanding, findOneByFood
might be called when a certain route is hit on an Express server, then if the find
(or any other operation) was successful, the data will be sent back to the done
function. I’m not sure if this is right though.
var findOneByFood = function(food, done) {
Person.find({favoriteFoods: food}, function(err, data) {
if(err) return console.log(err);
done(null, data);
});
};