using $lte operator In MongoDB
In this example, we are selecting those documents where the value of the salary field is less than equals to 1000.
Query:
db.contributor.find({salary: {$lte: 1000}}).pretty()
Output:
MongoDB – Comparison Query Operators
Comparison Query Operators in MongoDB are used to filter documents based on some specific criteria within their fields.
MongoDB uses various comparison query operators to compare the values of the documents. The following table contains the comparison query operators:
Operators | Description |
---|---|
$eq | Matches the values of the fields that are equal to a specified value. |
$ne | Matches all values of the field that are not equal to a specified value. |
$gt | Matches values of the fields that are greater than a specified value. |
$gte | Matches values of the fields that are greater than equal to the specified value. |
$lt | Matches values of the fields that are less than a specified value |
$lte | Matches values of the fields that are less than equal to the specified value |
$in | Matches any of the values specified in an array. |
$nin | Matches none of the values specified in an array. |
Contact Us