Querying

Mongo DB supporta query molto espressive per il recupero dei dati. Le query sono espresse in una notazione stile JSON, e trasmesse al server come BSON. Si possono interrogare tramite le query, anche gli oggetti embedded a gli array interni ad un document.

Il query optimizer del database analizza ciascuna query e genera un appropriato programma, usando gli indici quando disponibili.

Cursors

Le query, eseguite con il metodo find(), restituiscono un cursore. I cursori vengono poi utilizzati per recuperare in maniera iterativa tutti i documenti restituiti dalla query. Per esempio, usando la Mongo shell :

> var cur = db.example.find();
> cur.forEach( function(x) { print(tojson(x))});
{"n" : 1 , "_id" : "497ce96f395f2f052a494fd4"}
{"n" : 2 , "_id" : "497ce971395f2f052a494fd5"}
{"n" : 3 , "_id" : "497ce973395f2f052a494fd6"}
>

Vedi anche


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.

These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group.

blog comments powered by Disqus