You can use the method find()
to run a query that fetches documents from a Mongodb collection. All queries in Mongodb have as their scope a single collection.
Queries can return all documents from a collection, or only documents that match a particular filter or criteria.
You can specify the filter or criterion in a document and send it as parameter to the method find()
.
The method find()
returns results of a cursor, an iterable object that emits documents.
In the Mongo shell connected with an instance mongod, switch to the bank yoda
:
use yoda
To get all documents from the collection, you can call the method find()
without a criteria document. For example, the following operation fetches all documents in the collection configuracoes
:
db.configuracoes.find()
The result set contains all documents in the collection configuracoes
.
To define equal conditions, simply associate the field with the value:
{<campo>: <valor>}
In your case, you can do so:
db.configuracoes.find({"tipoRecibo": "gps"})