MongoDB Use model.findOne()

MongoDB Use model.findOne()
0

#1

Tell us what’s happening:
I am having difficulty completing this challenge. I was able to complete the previous challenge using Model.find(); but this one is not passing any data into my unnamed function (console.log is printing null), and I don’t know how the testing function works well enough to troubleshoot. Could someone tell me if I’m making some sort of simple error that I’m not seeing, or if there is a problem with the testing algorithm?

Your code so far

var findOneByFood = function(food, done) {
  Person.findOne({favoriteFood: food}, function(err, data) {
    console.log(data);
    if(err) return done(err);
    return done(null, data)
  })
  
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/apis-and-microservices/mongodb-and-mongoose/use-model-findone-to-return-a-single-matching-document-from-your-database


#2

it’s favoriteFoods, plural.


#3

Dang, it’s always something simple. Thanks for the second pair of eyes!