What is the difference between findByIdAndRemove and findByIdAndDelete in mongoose?
This function differs slightly from Model.findOneAndRemove() in that findOneAndRemove() becomes a MongoDB findAndModify() command, as opposed to a findOneAndDelete() command. For most mongoose use cases, this distinction is purely pedantic. You should use findOneAndDelete() unless you have a good reason not to.
the offical site https://mongoosejs.com/docs/api.html#model_Model.findOneAndDelete
There is no difference between them! ^_^
Let's look into the code, at the findByIdAndDelete()
, there is a note:
// Note: same signatures as findByIdAndRemove
and by findByIdAndRemove()
the same:
// Note: same signatures as findByIdAndDelete