MongoDB CRUD operation


What is a MongoDB CRUD operation?

The primary way to interact with a MongoDB server is called a CRUD operation. CRUD stands for Create, Read, Update, and Delete. These CRUD methods are the primary way to manage the data in your database.

Create Operation

The create or insert operation adds a new document to the collection, and if the collection does not currently exist, the insert operation creates it. In MongoDB, insert operations target a single collection, and all MongoDB write operations are atomic at the level of a single document.

Read operation

The read operation retrieves the document from the collection. That is, query the collection of documents. MongoDB provides the following methods for reading documents from collections.

Update operation

The update operation modifies an existing document in the collection. MongoDB provides the following methods for updating documents in a group. In MongoDB, update operations target a single collection. All MongoDB write operations are atomic at the level of a single document. You can specify criteria or filters that identify the documents you want to update. These filters use the same syntax as reading operations.

Delete operation

The delete operation deletes the document from the collection. MongoDB provides the following methods for removing documents from collections. In MongoDB, delete operations target a single collection. All MongoDB write operations are atomic at the level of a single document. You can specify criteria or filters that identify the documents you want to delete. These filters use the same syntax as reading operations.