Unable to pass Mongoose Delete Validation Test

Tell us what’s happening:
Test will not pass, though it matches the solution. All data gets deleted instead of just items with {name: “Mary”} if I follow the solution. I’ve tried many different ways and cannot get test to pass.

Your project link(s)

solution: https://replit.com/@13cbenjamin/boilerplate-mongomongoose

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Delete Many Documents with model.remove()

Link to the challenge:

Hello! Welcome to the community :grin:!

The template doesn’t work for version 6+ of mongoose.

For anyone having the same problem, please change your version of mongoose to be 5.13.8 in the package.json, then click Run (on repl.it) and try again:

"dependencies": {
        "body-parser": "^1.15.2",
        "dotenv": "^8.2.0",
        "express": "^4.12.4",
        "mongodb": "^4.1.1",
        "mongoose": "^5.13.8"

Your function takes only one argument - done.
How does it know what name to remove?
If I would like to remove name “Napoleon”, how would I call that function to do it?


Chris is doing what the task asks him to do, so it’s OK :slight_smile:.

It would be an error in a real life app, I agree, but if Chris fixes it, and we take into account that the challenge asks him to not edit the server.js file, it will not work.

1 Like

Ah, ok.
I did this a few weeks ago, but no server.js editing that I recall.
Also looked at my own code and it too was not taking another argument, but it passed the tests, strange.

Anyway, I leave the rest to the pros. ; )

1 Like

Hmmm, strange indeed. I may be missing something then :sweat_smile:… I’ll check again.

1 Like

Could you check, on your solution, which versions of mongoose and mongodb you have installed? (Or share the link to your solution through a private message, please).

Thank you So Much Skaparate. This resolved my issue! I thought it may be version related but was not sure which version to downgrade to.

The initial course instructions do not state which version to use. Below I’ve pasted in the instructions. I would recommend updating this section to state which versions to add which would avoid this problem for others. I assumed latest version if none provided.

Add mongodb and mongoose to the project’s package.json . Then, require mongoose as mongoose in myApp.js .

Yes, you’re correct. It was supposed to specify a version but we missed it :sweat_smile:. It will be fixed soon.

1 Like

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