You can use the find()
method to run a query which obtains documents from a MongoDB collection. All queries in MongoDB are scoped, a single collection.
Queries can return all documents in a collection, or only documents that match a particular filter or criteria.
Home
You can specify the filter or criteria in a document and send it as a parameter to the find()
.
The method find()
returns results from a cursor, a object that issues documents.
In the mongo shell connected to a mongod instance, switch to the yoda
:
use yoda
To get all the documents in the collection, you can call the method find()
without a criteria document. For example, the following operation fetches all documents in the configuracoes
collection:
db.configuracoes.find()
The result set contains all documents in the
configuracoes
collection.
To define equality conditions, simply associate the field with the value:
{<campo>: <valor>}
In your case, you can do this:
db.configuracoes.find({"tipoRecibo": "gps"})