now, i think i have to remove more than only one name, that in this case is “Mary”, i’ve tried to replace it with “Frankie” that’s a name present in my var arrayOfPeople that i inserted first in the code due to a previous lesson but doesn’t change anything, now my question is: do i have to remove more than the only name “Mary”? and if yes, how? do i have to change const nameToRemove filling it with an array of strings including more than one name? hope for your help, thank you.
I’ve noticed that in my database there are two objects, both with name: “Mary”, but with different array of favourite foods and age, i think these two object must be removed, but with that code it doesnt’t work, hope you can show me the way
UPDATE: i’ve checked my mongodb’s databse, the two objects including name:“Mary” are disappeared, but in the fcc’s lesson when i put my replit’s app link it doesn’t let me pass the lesson.
I would suggest you install the same versions of the dependencies as required in install and set up mongoose. Then delete the people collection from the DB and try again.
I won’t link to your Replit because you still have the connection string with the password in it.
Click the Secretes button.
Add MONGO_URI as the key
Add your DB connection string without the surrounding quotes as the value.
Access the connection string using process.env.MONGO_URI and remove the literal string from your code.
Uhhh this is just a note so it may be wrong cause I never know what I’m doing but I believe Mongoose has Deprecated the .remove() method.
So I did CTRL+F to try and find other methods that were described as .remove() in the documentation. Sure enough the .deleteMany() method had this in it’s description, " Behaves like remove(), but deletes all documents that match conditions regardless of the single option.".
Again I don’t know if this particular method does what we were trying to accomplish exactly but maybe this idea leads someone to find a correct answer. Also, at the end of the day my code still passed using this method.
This problem happened to me. I tested it locally and it didn’t return any errors with both Model.remove and Model.deleteMany, but on the platform it gave an error several times.