MongoDB - Query to find specific documents in a collection

Professionaluser
Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 248
find(<filter condition>) method accepts some filter criteria to fetch only particular documents from a collection in MongoDB. Below is the sample code for the same,

The following operation finds documents whose borough field equals "Manhattan".

>db.Person.Insert("name" : "XYZ", "PhoneNum" : 1234567890, "MailID" : "xyz123@gmail.com")
>db.Person.Insert("name" : "ABC", "PhoneNum" : 1234567890, "MailID" : "abc123@gmail.com")
>db.Person.find( { "name": "ABC" } )


output:
{"name" : "ABC", "PhoneNum" : 1234567890, "MailID" : "abc123@gmail.com"}

Comments or Responses

Login to post response