What is your hint or solution suggestion?
FindOneAndRemove() is similar with FindByIdAndRemove() - it take the person id as filter as the first argument , and a callback function at the second argument.
Solution: const removeById = (personId, done) => {
// _id is automatically generate and unique for each of the object store in MongoDB
Person.findOneAndRemove({ _id: personId } , function(err,result){
if(err) console.error(err);
done(null , result);
})
};
Challenge: Delete One Document Using model.findByIdAndRemove
Link to the challenge: