retrieve all documents in a collection
db.collection.find({});
retrieve documents in a collection using a condition ( similar to WHERE in MYSQL )
db.collection.find({key: value});
example
db.users.find({email:"[email protected]"});
retrieve documents in a collection using Boolean conditions (Query Operators)
//AND
db.collection.find( {
$and: [
{ key: value }, { key: value }
]
})
//OR
db.collection.find( {
$or: [
{ key: value }, { key: value }
]
})
//NOT
db.inventory.find( { key: { $not: value } } )
more boolean operations and examples can be found here
NOTE: find() will keep on searching the collection even if a document match has been found , therefore it is inefficient when used in a large collection , however by carefully modeling your data and/or using indexes you can increase the efficiency of find()