What is your hint or solution suggestion?
-
To delete a user’s
_id
you need to useModel.findByIdAndRemove
. However, there are other options which such as;Model.findOneAndRemove
orModel.findOneAndDelete
. -
Also, use the function argument
personId
as 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: