To continue my series on the CRUD (Create, Read, Update, Delete) API in MongoDB, we will talk about the ‘D’, deleting documents.
Note: I will be using the MongoDB shell in my terminal to show some examples. If you do not have it installed, please refer to my Quick start with MongoDB article
As always, MongoDB has explicit methods names to describe its actions. So, to delete documents from a collection, we have two methods: deleteOne() and deleteMany(). Both of these methods take a filter as their first parameter. Let’s see these in action:
Continue reading Removing documents in MongoDB