$gt / $gte / $lt / $lte

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Query filter operators

What it does

Range comparisons use BSON comparison semantics.

Syntax

{ field: { $gte: value } }

Use case

Filter prices, dates, or thresholds.

$gt /$gte /$lt /$lte: practical example
db.orders.find({ total: { $gte: 1000, $lt: 5000 } })
💡 Explanation Range comparisons use BSON comparison semantics. When to use it Filter prices, dates, or thresholds.
Key Takeaways
  • Range comparisons use BSON comparison semantics.
  • Typical use: Filter prices, dates, or thresholds.