Doubt with mongodb test

1

I'm new to mongo with a query with select / query.

I need to do a query that searches the base yoda and the collection configuracoes to return all documents that have the tipoRecibo key with the value equal to gps .

I know I have to use

$filter
= array

collection forward caught me, if anyone gives me a super help, thank you.

    
asked by anonymous 26.10.2016 / 00:51

2 answers

3

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"})
    
26.10.2016 / 20:57
1

Man, you need to see all the basic operations of the mongo I suggest these references here, they have helped me a lot in my day to day.

link

link

The mongo is sensational you will see in time. Success !!

    
01.11.2016 / 19:59