MongoDB is the Document-Based distributed database system that provides rich functionality to read and write the data and these operations are achieved through MongoDB CRUD. The MongoDB CRUD stands for CREATE, READ, UPDATE and DELETE which are used to perform the operation such as create, update, read and delete on MongoDB Documents. Using these operations we can easily interact with the database and perform various tasks.
The following figure represents the MongoDB CRUD operation.
MongoDB CRUD Concepts
The MongoDB CRUD concept has two operations, the first one is Read Operation and the second one is Write operation. In Read Operation we have READ operation and in the Write operation we have CREATE, UPDATE AND DELETE operation as mentioned in the below figure.
Let us understand the MongoDB CRUD operations in the below section.
Create Operations in MongoDB
MongoDB Create Operations are used to create a new Document in a Collection. In case the Collection is not present then it creates the Collection as well.
The below two methods are used for MongoDB Create Operations.
In the following example, we can see the Collection "users_detail" is created with the below data.
Read Operations in MongoDB
MongoDB Read Operations are used to read the Documents from the Collection.
MongoDB provides the following method to perform the Read Operations.
The following is an example of Read Operations in MongoDB.
Update Operations in MongoDB
MongoDB Update Operations are used to modify existing Documents in the Collection.
The following methods are used to perform the Update Operations in MongoDB.
The following is an example of Update Operations in MongoDB.
Delete Operations in MongoDB
MongoDB Delete Operations are used to delete the Documents from the Collection.
The following methods are used to perform the Delete Operations in MongoDB.
The following is an example of Delete Operations in MongoDB.