|
MongoDB features a rich language for performing dynamic queries. Query SelectorsMongoDB supports a number of query expressions for fetching data. Queries are expressed in a JSON-style notation and transmitted to the database server as BSON. Queries on document keys include the ability to match against both embedded objects and arrays within a document. The database's query optimizer analyzes each query and generates an appropriate plan, using indexes when available. CursorsDatabase queries, performed with the find() method, return a cursor. Cursors are then used to iteratively retrieve all the documents returned by the query. For example, in the 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"} > See Also |

Add Comment