Mongoose, Tests not passing even thought code is right

Tell us what’s happening:
I have been doing this for 3 days now, and 99.99% sure its correct, the challenge isn’t passing tho :confused:

Your code so far

var queryChain = function(done) {
  var foodToSearch = "burrito";
  console.log(foodToSearch);
  Person.find({ favoriteFoods: [foodToSearch] })
    .sort({ name: "asc" })
    .select("-age")
    .limit(2)
    .exec(function(error, people) {
    if (error) console.error(error)
    done(null, people)
  });
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0.

Challenge: Chain Search Query Helpers to Narrow Search Results

Link to the challenge:

Hello there,

The only thing I can think to suggest, without having seen the rest of your code, is to follow the format in the instructions exactly.

.find() , .sort() , .limit() , .select()

Keep that order of operations.

Also, when I did it, I passed 'find' as the first argument to .exec

Hope this helps

Hello, Thanks for the helpful insight. It didn’t work though :frowning:

In that case, could you please post a link to your project?

Here:


Line 227

Actually, I do not know why i missed this: Why did you place the foodToSearch inside an array?

favoriteFoods: [foodToSearch]
1 Like

Hahaha! That worked! I thought to that to find something inside an array you use this syntax :laughing: