Please Advise for the Error Below

In the ‘Back end and API’'s certification, the lesson ‘Delete many documents with model.remove’ shows this error (below 1) when you run in Replit to validate with FCC website. I found this information on the MongoDB website about the depreciated (below 2) with the link to the page (below 3.) When I go to validate, FCC will not validate and Replit will not run the program. I am ALMOST certain the syntax is correct for the given lesson (below 4.) Please advise what I should do. All of this is very new to me and I might be missing something.

  1. (node:956) [MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.

  2. There are several deprecations in the MongoDB Node.js driver that Mongoose users should be aware of. Mongoose provides options to work around these deprecation warnings, but you need to test whether these options cause any problems for your application. Please report any issues on GitHub.

Summary

To fix all deprecation warnings, follow the below steps:

  • Replace update() with updateOne(), updateMany(), or replaceOne()
  • Replace remove() with deleteOne() or deleteMany().
  • Replace count() with countDocuments(), unless you want to count how many documents are in the whole collection (no filter). In the latter case, use estimatedDocumentCount().

Read below for more a more detailed description of each deprecation warning.

  1. Mongoose v6.4.1: Deprecation Warnings (mongoosejs.com)

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

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

Your browser information:

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

Challenge: Delete Many Documents with model.remove()

Link to the challenge:

The problem is you are not using the correct version of mongoose specified in the first challenge of this project. Change it to the correct version, run npm install (unless repl.it does it automatically).

The test on the challenge you are failing does so because the version of mongoose you specified in your package.json file does not have the model.remove() method.

UPDATE: I just created a PR to make the tests of the first challenge of the MongoDB and Mongoose section more strict about the versions of MongoDB and Mongoose, this particular challenge’s test will not fail with valid code.

This is the error now. I copied the version numbers for Mongoose and MongoDB and this is the new error I am getting. I have spent like 6 hours between yesterday and today trying to diagnose this myself. If you have any suggestions or I can assist in any way please let me know as I would like to go through all the lessons and information.

Your MONGO URI does not include your database name at the end of it.

I modified your URI below (removing username and password) so you can see where the database name should be located.

mongodb+srv://userNameGoesHere:passwordGoesHere@cluster0.dehexay.mongodb.net/dataBaseNameGoesHere?retryWrites=true&w=majority

NOTE: You really should be using the Secrets feature of repl.it to store you URI since it contains a username and password.