Query for MONGODB data:
Find Method:
function (Query, field, limit, skip, batchsize, options) {/*query : Query condition fields: Returns the column limit: Skip: batchsize: options: */}
View Code
Querying all data in a collection
Db.user.find (); // When you do not specify a query condition, the default is {} empty document
Specify the fields that need to be returned: By default the _id field is returned, and if you do not want to render the _id field, you can set _id:0 to not return
var key={ "age": 1, "name": 1}db.user.find ({},key);
Query criteria:
"$lt", "$gt", "$lte", "$gte" operators:
var action={ "age": {"$lte": +, "$GT": +}//20<age<=30} var key={ "_id": 0,// do not return _id, return the age, Name field, other fields do not return "age" by default : 1, "name": 1 }db.user.find (action,key);
"$or", "$in" operators:
var action={ "$or": [ {"$in": [20,25]}}, {"name": {"$ In ": [" Zhang Jie "," Ziyi "]}} ]}var key= {" _id ": 0,// do not return _id, return age, Name field, other fields do not return "age" by default:1 ,"name": 1 }db.user.find (action,key);
"$and" operator:
Cond..
MongoDB Learning Notes (iii)