$lt (Less Than)

Last updated: 2026-10-09

$lt (Less Than)

$lt selects documents where a field value is strictly less than the specified value. `{ price: { $lt: 20 } }` matches products priced under 20. It handles price caps, cutoff dates and score ceilings, and combines with $gt for an open interval. Strings compare lexicographically, dates chronologically; $lt is type-sensitive.

CategoryComparison
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

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

⚙️ Parameters

fieldThe document field to match.
valueThe upper-bound value; the boundary itself is excluded.

Returns:Cursor of matching documents

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// $lt: products priced under 20
db.products.find({ price: { $lt: 20 } })

// Users registered before the cutoff date
db.users.find({ registeredAt: { $lt: new Date('2026-01-01') } })

Output:

// Returns products under 20 and users registered before Jan 1, 2026

📌 Notes

📚 Related Tutorials

❓ FAQ

QWhat is the difference between $lt and $lte?
A$lt is strictly less (excludes the boundary); $lte includes it. Use $lt: 20 for below 20 and $lte: 20 for at most 20.
QHow do I query scores between 60 and 90?
ACombine on one field: { score: { $gt: 60, $lt: 90 } } — an open interval.
QWhat should I watch for when using $lt on dates?
AWrap dates in new Date('YYYY-MM-DD'); raw strings compare lexicographically and can surprise you.
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%

🙏 帮我们做得更好

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

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