MongoDB in Find function syntax: Db.collection.find (QUERY,FILEDS,LIMIT,SIKP)
1. The Qurey parameter is equivalent to the WHERE clause in SQL to indicate the query condition column: Db.account.find ({name: "Lewesyang", age:{$it: 22})
2. The fileds parameter corresponds to the field syntax format after select: db.account.find ({name: "Lewesyang", age:{$it: 22}},{"Age": 0})
The meaning does not return the Age field note (cannot be returned and does not return mixed with both {"Age": 0, "name": 1} is not legal) is recommended either to write or not to return the write
3. Limit parameter limits the number of returned result documents, specifying the maximum number of returned results:
Db.account.find ({name: "Lewesyang", age:{$it: 22}},{"age": 0},5) returns up to 5 legitimate documents
4. Skip parameter when querying document offset:db.account.find ({name: "Lewesyang", age:{$it: 22}},{"age": 0},5,10) return 5 document record 11~16 bar starting from 11th
Use the limit and skip syntax alone: db.account.find (). Limit (5). Skip (Ten)
The Find function query handles documents that are unordered in order to get an ordered document that requires the Sort function syntax:db.account.find (). Sort ({age:-1}) in descending order of age
The return value of the Find function is a cursor object, and the sort function is provided by the cursor object, and the Find function query does not return all legitimate documents at once for the first time to return 101 or 200M of data and cache it to memory . The cursor works. You can use it to sort operations on the result set, thecursor records the access location, and when the in-memory document is accessed, the cursor sends a query data request to the database again
MongoDB Find function usage