$lt

The `$lt` operator retrieves documents where the value of a field is strictly less than a specified value.

Syntax

{ field: { $lt: value } }

Parameters

fieldstringrequired

The field in the document you want to evaluate

valuenumberrequired

The value to compare against; documents where field is less than this value will match

Examples

Find stores with sales below $36,000

To find stores with less than $36,000 in sales, run a query using $lt on the sales.totalSales field.

Query:

db.stores.find({
    "sales.totalSales": { $lt: 36000 }
}, { name: 1, "sales.totalSales": 1 }, { limit: 1 })

Output:

[{ "_id": "e6895a31-a5cd-4103-8889-3b95a864e5a6", "name": "VanArsdel, Ltd. | Picture Frame Store - Port Clevelandton", "sales": { "totalSales": 17676 } }]

Related