Read Operations
The Read operations are used to retrieve documents from the collection, or in other words, read operations are used to query a collection for a document.
You can perform read operation using the following method provided by the MongoDB:
Method | Description |
---|---|
db.collection.find() | It is used to retrieve documents from the collection. |
Note: pretty() method is used to decorate the result such that it is easy to read.
Read Operations Example
Let’s look at some examples of Read operation from CRUD in MongoDB.
Example: In this example, we are retrieving the details of students from the student collection using db.collection.find() method.
MongoDB CRUD Operations
CRUD Operations (Create, Read, Update, and Delete) are the basic set of operations that allow users to interact with the MongoDB server.
As we know, to use MongoDB we need to interact with the MongoDB server to perform certain operations like entering new data into the application, updating data into the application, deleting data from the application, and reading the application data.
In this article, we will learn all 4 major operations– CREATE, READ, UPDATE, and DELETE that form the CRUD operations in MongoDB.
Contact Us