$lt < less than
$lte <= less than and equal smaller than or equal to
$GT > greater than greater than
$gte >= greanter than and equal greater than or equal to
$ne! = Not equal range
The simple usage is as follows:
Demand:
Users less than 30 are queried:
Db. user. Find ({age:{$lt:}},{_id:0});
Requirements: 18-25-year-old users are queried
Db. user. Find ({age:{$gte:$lte:)});
Note: Here is a feature that is for the age of the key to query, can be in the object of the comparison operator, write multiple, it is to meet the conditions therein.
Demand:
Find a 18-25-year-old male and user
Db. user. Find ({$and:[{sex: ' Male '},{age:{$gte: $lte:]}]},{_id:0 });
Demand:
Check with 18 or 25-year-old users
Db. user. Find ({$or:[age:18],[age:22] },{_id:0});
Here we have a feature, that is, for age to compare, if this is the case, we can also use $in to achieve the same effect
Db. user. Find ({age:{$in:[18,22]}},{_id:0});
Search for a person who is gender-or between 18-25 years of age:
Db. user. Find ({$or:[{sex: ' Male '},{age:{$gte: $lte:]}]},{_id:0 })
Non-operation, which is our common inversion:
Querying users who are not 18-22
Db. user. Find ({age:{$not: {$gte:$lte:}}},{_id:0})
Life Lei dog MongoDB----MONGODB---3---comparison operator