Remove document from collection in MongoDB with remove()

Last update on April 14 2018 06:14:57 (UTC/GMT +8 hours)

Description

We have already learned how to insert records into a collection and also learned how to update the document within a collection based on certain criteria. In this page, we are going to discuss how to remove the document and entire collection.

remove() is used to remove a document and a collection. It may be a good practice if you execute a find() before removing a document as you can fix criteria for removing the document.

Our database name is 'myinfo' and our collection name is 'userdetails'. Here, inserting one more record.