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:

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.

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