Solution not accepting

Tell us what’s happening:
Describe your issue in detail here.

“Chaining query helpers should succeed (Test timed out)”
I think my code is correct but the solution not accepting

const foodToSearch = "burrito";
  Person.find({favoriteFoods: foodToSearch}).sort({name: 'asc'}).limit(2).select("-age").exec(function(error, people) {

    done(null, people);

Your project link(s)

solution: boilerplate-mongomongoose - Replit

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Chain Search Query Helpers to Narrow Search Results

Link to the challenge:

If you inspect the network requests you can see this response

E11000 duplicate key error collection: fcc-mongodb-and-mongoose.people index: favoriteFoods_1 dup key: { favoriteFoods: "burrito" }

This is caused by the use of unique: true in the schema.

You probably have to delete the collection as well. Atlas dashboard > Databases > Browse Collections > Delete the “people” collection.

Now try the submit again.

Edit: as an aside, you really do not want your connection string with the username and password in the code. Use a .env file (or the secretes tab on Replit). I guess it’s OK when asking for help but then you should change the password afterward.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.