Mongodb Classroom image

Anil  Bist / Professional / DataBase

To post your Question Join Classroom
Lesson Topics's No:-  ||


Query for all the docs in the people collection that have a name field with a value of 'Tom':

db. people.find ( { name: 'Tom' } )


Or just the first one:

db. people.findOne ({name: ' Tom '})  


You can also specify which fields to return by passing a field selection parameter. The following will exclude the _id field and only include the age field:

db. people.find ( { name: 'Tom' }, { _id: 0, age: 1 })  


Note: by default, the _id field will be returned, even if you don't ask for it. If you would like not to get the _id back, you can just follow the previous example and ask for the _id to be excluded by specifying _id: 0 (or _id: false).If you want to find sub record like address object contains country, city, etc.

db. people.find ( { '': 'US' } )  


& specify field too if required


Anil  Bist

Skills    Mongodb

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a


  Students (0)