![]() ![]() ![]() In order to fetch specific fields, we have to use projection within the find method. In the following example, we are going to fetch the record by staff ID, where the staff ID is equal three and it will return us only that document. This parameter will help us to fetch only that record which meets the criteria. In order to fetch a specific document from the MongoDB collection, we can use a query parameter in the find method. In simple words, we will not use any parameter when we need all the records. In order to fetch all the records that are available within a collection, we need to use the find method having an empty parameter. In simple words, it is a kind of decision making which will take the decision upon the criteria. ![]() Projection – This is an optional parameter which defines what to return when the query criteria successfully meet. In simple words, what you want to search within a collection will be defined as a query. Query – This is an optional parameter which defines the selection criteria. If we don’t use these two parameters then the find method will return all the documents available within the MongoDB collection. There are totally six methods available in Mongo DB by which we can fetch particular records.įind method consists of two parameters by which we can fetch a particular record. Find Specific Documents with Conditional Criteriaįind method in MongoDB Query is used to fetch a particular document from the MongoDB collection. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |