$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.

CategoryComparison
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

{ <field>: { $gte: <value> } }

⚙️ Parameters

fieldThe document field to match; dotted paths access nested fields.
valueThe 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

📚 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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏