$lte (Less Than or Equal)
Last updated: 2026-10-09
$lte (Less Than or Equal)
$lte selects documents where a field value is less than or equal to the specified value. `{ price: { $lte: 50 } }` matches products priced at most 50. It expresses at-most semantics and pairs with $gte to form a closed range — common for discounts and limits, and index-friendly.
| Category | Comparison |
|---|---|
| MongoDB Version | 1.0+ |
| Example Language | mongosh (Shell) |
📝 Syntax
{ <field>: { $lte: <value> } }
⚙️ Parameters
| field | The document field to match. |
|---|---|
| value | The upper-bound value; the boundary itself is included. |
Returns:Cursor of matching documents
▶ Example
Run the commands below in your local mongosh (requires a running mongod):
// $lte: products priced at most 50
db.products.find({ price: { $lte: 50 } })
// Closed range: qty from 1 to 10
db.orders.find({ qty: { $gte: 1, $lte: 10 } })
Output:
// Returns products at most 50 and orders with qty between 1 and 10
📌 Notes
- $lte includes the boundary; use $lt to exclude it
- Pair with $gte for a closed range; both ends can use an index
- Different types never compare: number 50 and string '50' neither equal nor order
🏷️ Related Tags
💡 Related Cases
Document Query Basics: The `find` Method and Projections
Query Operators: A Complete Guide to the 30+ Operator
📚 Related Tutorials
❓ FAQ
QCan $lte filter dates up to today?
AYes, compute the end-of-day in code: { createdAt: { $lte: new Date('2026-09-30T23:59:59') } }.
QWhat is the difference between $lte and $lt?
A$lte includes equality; $lt is strictly less. Use $lte: 50 for at most 50.
QHow do I query qty between 1 and 10?
A{ qty: { $gte: 1, $lte: 10 } } — both ends inclusive.