AWS documentdb documentation change
Summary
Added new documentation page for the $gt query operator with examples in MongoDB Shell, Node.js, and Python, including connection strings with TLS configuration
Security assessment
The change adds documentation for a standard query operator ($gt) with code examples that include secure connection parameters (tls=true, tlsCAFile=global-bundle.pem). This promotes security best practices by demonstrating encrypted connections to DocumentDB, but does not address a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/gt.md b/documentdb/latest/developerguide/gt.md index 8b1378917..9aa38ae33 100644 --- a//documentdb/latest/developerguide/gt.md +++ b//documentdb/latest/developerguide/gt.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#gt "Open PDF") @@ -1,0 +3,98 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $gt + +The `$gt` operator in Amazon DocumentDB is used to select documents where the value of the specified field is greater than the specified value. This operator is useful for filtering and querying data based on numerical comparisons. + +**Parameters** + + * `field`: The field to compare. + + * `value`: The value to compare against. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$gt` operator to find all documents where the `age` field is greater than 30. + +**Create sample documents** + + + db.users.insertMany([ + { name: "John", age: 25 }, + { name: "Jane", age: 32 }, + { name: "Bob", age: 45 }, + { name: "Alice", age: 28 } + ]); + +**Query example** + + + db.users.find({ age: { $gt: 30 } }); + +**Output** + + + { "_id" : ObjectId("6249e5c22a5d39884a0a0001"), "name" : "Jane", "age" : 32 }, + { "_id" : ObjectId("6249e5c22a5d39884a0a0002"), "name" : "Bob", "age" : 45 } + +## Code examples + +To view a code example for using the `$gt` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findUsersOlderThan30() { + const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'); + const db = client.db('test'); + const users = await db.collection('users').find({ age: { $gt: 30 } }).toArray(); + console.log(users); + await client.close(); + } + + findUsersOlderThan30(); + +Python + + + + from pymongo import MongoClient + + def find_users_older_than_30(): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client.test + users = list(db.users.find({ 'age': { '$gt': 30 } })) + print(users) + client.close() + + find_users_older_than_30() + + **Javascript is disabled or is unavailable in your browser.** + +To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions. + +[Document Conventions](/general/latest/gr/docconventions.html) + +$expr + +$gte + +Did this page help you? - Yes + +Thanks for letting us know we're doing a good job! + +If you've got a moment, please tell us what we did right so we can do more of it. + +Did this page help you? - No + +Thanks for letting us know this page needs work. We're sorry we let you down. + +If you've got a moment, please tell us how we can make the documentation better.