MONGO Simple Query
Db.ansheng.findOne ()//returns the first match to the data
Db.ansheng.findOne ({"AAAAA": 4})
Db.ansheng.find ()//The simplest query
Db.ansheng.find ({"AAAAA": 2})//returns the matched data
Db.ansheng.find ({"AAAAA": 2}). Limit (1)//Returns the specified number of bars (limit) data based on the query criteria (find)
Db.ansheng.find ({"AAAAA": 2}). Skip (1). limit (1);//Hit n data based on query criteria (find), skip previous (skip) bar data, return (limit) bar data
Db.ansheng.find ({"AAAAA": 2}, "book": ["Looking for hope in despair"])
Db.ansheng1.find ({aaa:123, bbb:3211})//Multiple query statements
Returns the specified key
Sometimes it is not necessary to return all key/value pairs in the document, which can be used to return the specified key with the second parameter of find.
Db.ansheng.find ({},{aaaaa:1, list:1})
Db.ansheng.findOne ({},{aaaaa:1, list:1})
By default, _id is always returned, which can be eliminated by using the second parameter.
Db.ansheng.find ({},{_id:0,aaaaa:1})
Db.ansheng.find ({},{_id:0})//If only 0 is entered, all other parameters are returned
Query for the specified scope
In the query we often encounter more than how much
"$lt", "$lte", "$gt", "$gte" correspond respectively
< <= > >=
Summary of queries in MONGO