Help! MongoDB and Mongoose - Chain Search Query Helpers to Narrow Search Results

I have been trying to pass this challenge but to no success. The output looks like this:

// running tests
E11000 duplicate key error collection: test.people index: favoriteFoods_1 dup key: { : "burrito" }
// tests completed

Can someone help me with this?

var queryChain = function(done) {
  var foodToSearch = "burrito";

  Person.find({favoriteFoods: foodToSearch})
        .sort({name: "asc"})
        .limit(2)
        .select({age: 0})
        .exec((err, data) => err ? done(err) : done(null, data));
};

Try dropping your collection in your mlab or atlas whatever you are using and run the code again.

2 Likes

It worked! Thank you so much, this has been bugging me for a long time.