$gte
The $gte operator in Amazon DocumentDB is used to match values that are greater than or equal to a specified value. This operator is useful for filtering and querying data based on numerical comparisons.
Parameters
-
field: The field to check against the provided value. -
value: The value to compare against the field.
Example (MongoDB Shell)
The following example demonstrates the usage of the $gte operator in Amazon DocumentDB to find all documents where the "age" field is greater than or equal to 25.
Create sample documents
db.users.insertMany([ { _id: 1, name: "John", age: 20 }, { _id: 2, name: "Jane", age: 25 }, { _id: 3, name: "Bob", age: 30 }, { _id: 4, name: "Alice", age: 35 } ]);
Query example
db.users.find({ age: { $gte: 25 } }, { _id: 0, name: 1, age: 1 });
Output
{ "name" : "Jane", "age" : 25 }
{ "name" : "Bob", "age" : 30 }
{ "name" : "Alice", "age" : 35 }
Code examples
To view a code example for using the $gte command, choose the tab for the language that you want to use: