this is the code I wrote to pass this challenge :
const removeById = (personId , done) => {
Person.findByIdAndRemove(personId , (err, IdRemoved) => {
if(err) {
console.log(err);
}else{
return done(null, IdRemoved);
};
});
};
but I get this error every time I run the code and I can’t figure out how to solve it
error :
(node:4856) [MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
(Use node --trace-warnings ...
to show where the warning was created)
{
_id: new ObjectId(“61ea9c7c7358ecc0f0218f41”),
name: ‘Jason Bourne’,
age: 36,
favFood: ,
__v: 0
}
{
_id: new ObjectId(“61ea9c7c7358ecc0f0218f41”),
name: ‘Jason Bourne’,
age: 36,
favFood: ,
__v: 0,
count: 0
}
Your project link(s)
solution: http://localhost:3000
Challenge: Delete One Document Using model.findByIdAndRemove
Link to the challenge: