1, the condition >,<,>=,<= in MongoDB the wording
: $gt, <: $lt, >=: $gte, <=: $lte, <>: $ne
Specific Use method:
Db.class.find ({"filed": {$GT: Value}}) Filed>value
Db.class.find ({"filed": {$lt: Value}}) Filed<value
Db.class.find ({"filed": {$gte: Value}}) Filed>=value
Db.class.find ({"filed": {$lte: Value}}) Filed<=value
Db.class.find ({"filed": {$gt: Value, $lt: value1}}) Value1>filed>value
Db.class.find ({"filed": {$ne: 5}}) Filed<>value
Db.class.find ({"Stucount": {$gt:ten}}) Db.class.find ({"Stucount": {$gte:Ten}})
Db.class.find ({"Stucount": {$lt:ten}}) Db.class.find ({"Stucount": {$lte:Ten}})
Db.class.find ({"Stucount": {$lt:ten, $gt:5}})
Db.class.find ({"Stucount": {$ne: 5}})
2. $all Match All
This operator is similar to the SQL syntax in, but the difference is that in only one value of () is satisfied, and the $all must be
All values within [] must be met
Db.class.find ({stucount:{$all: [6,8]}}) query result is empty
Db.class.find ({stucount:{$all: [6]}) can find one, equivalent to Db.class.find ({"Stucount": 6})
3. $in contains
Is the same as the purpose of SQL standard syntax, which is to query a range of enumerated values
Db.class.find ({stucount:{$in: [6,8]}})
4. $nin does not contain
Db.class.find ({stucount:{$nin: [6,8]}})
5. Determine if a field exists
Db.class.find ({stucount:{$exists: true}})
6. Null value processing
Db.class.find ({name:null}) will query for data that does not have a name field
Db.class.find ({name:{"$in": [null], "$exists": True}}) The query result has a name field and Name=null
7, $mod to take surplus
Db.class.find ({stucount:{$mod: [7,2]}}) equals 2 for 7
"MongoDB First Knowledge"-conditional operator