Even the solution provided by freecodecamp does not work for removing all the documents of a Model

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

The issue is that the tests fail although I have even copied the solution provided by freecodecamp and refreshed the page many times; stopped and started the replit server a few times but in spite of all this the tests fail and give the message:

// running tests
Deleting many items at once should succeed
// tests completed

I can not proceed to the next step. There should be some way to go ahead if the tests fail due to some problems at freecodecamp which the students don’t know about.

What can be done to solve this problem?
The solution that fails the tests is here:

const removeManyPeople = (done) => {
  const nameToRemove = "Mary";
  Person.remove({ name: nameToRemove }, (err, response) => {
    if (err) return console.log(err);
    done(null, response);
  })
};

Your project link(s)

solution: https://replit.com/@innovations/boilerplate-mongomongoose

Your browser information:

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

Challenge: Delete Many Documents with model.remove()

Link to the challenge:

You might want to try deleting all your browser’s history, caches and everything. At one point I did experienced of keep getting error the same error whatever I did and passed the specs after I cleaned up the browser’s history, thus a False Negative. Who knows.

If you want to skip around to other instructions, you can always click at the very top of the page to get to the overview of that particular curriculum, and just click on any specific bullet you want to try working on.

I don’t know that this is the issue - I’m spit balling here…

The original assignment said:

Add mongodb@~3.6.0 and mongoose@~5.4.0 to the project’s package.json .

And in your package.json, I see:

    "mongoose": "^6.1.2",
    "mongodb": "^3.0.0"

The issue that I can see is that I think the remove method was deprecated in version 6, as stated here.

2 Likes

Yes, you are right as I tried everything including Promises and examples given in the official documentation of the function deleteMany() but the freecodecamp test would not pass it. Finally, I had to install mongodb@~3.6.0 and mongoose@~5.4.0 and the tests passed.

1 Like

Yeah, a version number can make a big difference. At work, whenever we update a package (especially for a major version change), we do it very cautiously.

1 Like

This worked for me too! Thank you!

1 Like

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