|< < 44 > >|

Querying MongoDB

A MongoDB query is specified through a function on collections.
db.users.find( { age: {$gt: 60}}, { name: 1, address: 1})

  • Returns a cursor (i.e. iterator).

  • Query specified as a JSON document.
    • { age: {$gt: 60}}: Find document in the users collection with a top-level age field > 60.
    • { name: 1, address: 1}: Project on name and address. name: 0 means that the name field should be excluded.

|< < 44 > >|