$lt
The $lt operator in Amazon DocumentDB is used to match values that are less than the specified value. This operator is useful for filtering and querying data based on numerical comparisons.
Parameters
-
field: The field name to check. -
value: The value to compare against.
Example (MongoDB Shell)
The following example demonstrates how to use the $lt operator to retrieve documents where the Inventory.OnHand value is less than 50.
Create sample documents
db.example.insertMany([ { "_id": 1, "Inventory": { "OnHand": 25, "Sold": 60 }, "Colors": ["Red", "Blue"] }, { "_id": 2, "Inventory": { "OnHand": 75, "Sold": 40 }, "Colors": ["Red", "White"] }, { "_id": 3, "Inventory": { "OnHand": 10, "Sold": 85 }, "Colors": ["Red", "Green"] } ]);
Query example
db.example.find({ "Inventory.OnHand": { $lt: 50 } })
Output
{ "_id" : 1, "Inventory" : { "OnHand" : 25, "Sold" : 60 }, "Colors" : [ "Red", "Blue" ] }
{ "_id" : 3, "Inventory" : { "OnHand" : 10, "Sold" : 85 }, "Colors" : [ "Red", "Green" ] }
Code examples
To view a code example for using the $lt command, choose the tab for the language that you want to use: