Model.remove() give me problem! :(

Hi, i’m studying this lesson, i wrote the following code, following this hint

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

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. :thinking:

Hello there,

Would you mind sharing a link to your code on Replit?

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.

  1. Click the Secretes button.

  2. Add MONGO_URI as the key

  3. Add your DB connection string without the surrounding quotes as the value.

  4. Access the connection string using process.env.MONGO_URI and remove the literal string from your code.

1 Like

That worked! Thank you! So sofisticated this back-end development :joy:

Link edited in that post! I need to study cybersecurity i think :joy:

@mtssmoreno Your code is passing for me.

Your link is passed now!Could you share me you code?

Thank you. I have the same problem and your solution works for me

I try it but it doesn’t work, pls help me.

Without seeing your code we can’t help. Post your Replit.

It might be better if you opened your own thread.

1 Like