What is your hint or solution suggestion?
-
To delete a user’s
_idyou need to useModel.findByIdAndRemove. However, there are other options which such as;Model.findOneAndRemoveorModel.findOneAndDelete. -
Also, use the function argument
personIdas search key. -
Solution:
const removeById = (personId, done) => { Person.findByIdAndRemove(personId, (err, data) => { if (err) return console.log(err); done(null, data); }); };
Challenge: Delete One Document Using model.findByIdAndRemove
Link to the challenge: