MongoDB CRUD Operations
MongoDB CRUD Operations
MongoDB provides a set of some basic but most essential operations that
will help you to easily interact with the MongoDB server and these operations
Method Description
Method Description
Example : In this example, we are retrieving the details of students from the
student collection using db.collection.find()
method.
Update Operations –
The update operations are used to update or modify the existing document in
the collection. You can perform update operations using the following
methods provided by the MongoDB:
Method Description
It is used to update a single document in the collection
db.collection.updateOne() that satisfy the given criteria.
Example 1: In this example, we are updating the age of Sumit in the student
collection using db.collection.updateOne()
method.
Example 2: In this example, we are updating the year of course in all the
documents in the student collection using db.collection.updateMany()
method.
Delete Operations –
The delete operation are used to delete or remove the documents from a
collection. You can perform delete operations using the following methods
provided by the MongoDB:
Method Description