$gte (Greater Than or Equal)
Last updated: 2026-10-09
$gte (Greater Than or Equal)
$gte selects documents where a field value is greater than or equal to the specified value. `{ age: { $gte: 21 } }` matches users aged 21 and older. It is the inclusive counterpart of $gt, used for at-least semantics: age floors, minimum stock, time windows. Combine with $lte for a closed range.
| Category | Comparison |
|---|---|
| MongoDB Version | 1.0+ |
| Example Language | mongosh (Shell) |
📝 Syntax
{ <field>: { $gte: <value> } }
⚙️ Parameters
| field | The document field to match; dotted paths access nested fields. |
|---|---|
| value | The lower-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):
// $gte: users aged 18 or older
// Age exactly 18 is included
db.users.find({ age: { $gte: 18 } })
// Closed range: ages 18 through 30
db.users.find({ age: { $gte: 18, $lte: 30 } })
Output:
// Returns users with age at least 18, plus those in the closed range 18-30
📌 Notes
- $gte includes the boundary; that is its only difference from $gt
- Numbers, strings and dates all compare, but mismatched types never match
- If you reverse the bounds with $lte (e.g. $gte: 30, $lte: 18) nothing will match
🏷️ Related Tags
💡 Related Cases
Document Query Basics: The `find` Method and Projections
Query Operators: A Complete Guide to the 30+ Operator
📚 Related Tutorials
❓ FAQ
QWhich performs better, $gte or $gt?
AIdentical performance, both can use indexes. Choose based on whether the boundary should be included.
QHow do I query products with at least 10 in stock?
AUse $gte as the floor: { stock: { $gte: 10 } }.
QDoes $gte match null?
ANo. null does not compare against numbers, so $gte only matches comparable values of the same type.