MongoDB provides the following methods to read documents from a collection:
1
db.collection.find()
2
db.collection.findOne()
To select all documents in the collection, pass an empty document as the query filter parameter to the find method:
Equality condition:
The following example retrieves all documents from the inventory collection where status equals either 'A' or 'D':
A compound query can specify conditions for more than one field in the collection's documents. Implicitly, a logical AND conjunction connects the clauses of a compound query so that the query selects the documents in the collection that match all the conditions.
Using the $or operator, you can specify a compound query that joins each clause with a logical OR conjunction so that the query selects the documents in the collection that match at least one condition.