How to delete a document from MongoDB Collection using Mongoose in Node.js?
There are multiple methods that we can use to delete a document from MongoDB collection. These methods are deleteOne(), findByIdAndDelete() etc.
In this post we will be learning how we can delete a document using findByIdAndDelete() method.
Before Performing deletion operation:
Code:
User.findByIdAndDelete( 66e565177554c41a09a6fbb8 );