AWS documentdb documentation change
Summary
Added new documentation page for the $eq 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 query operator and includes example connection strings that demonstrate security best practices (TLS=true, tlsCAFile parameter). This shows how to securely connect to DocumentDB but doesn't address a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/eq.md b/documentdb/latest/developerguide/eq.md index 8b1378917..760eb6d1a 100644 --- a//documentdb/latest/developerguide/eq.md +++ b//documentdb/latest/developerguide/eq.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#eq "Open PDF") @@ -1,0 +3,102 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $eq + +The `$eq` operator in Amazon DocumentDB is used to match documents where the value of a field is equal to the specified value. This operator is commonly used in the `find()` method to retrieve documents that meet the specified criteria. + +**Parameters** + + * `field` : The field to check for the equality condition. + + * `value` : The value to compare against the field. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the usage of the `$eq` operator to find all documents where the `name` field is equal to `"Thai Curry Palace"`. + +**Create sample documents** + + + db.restaurants.insertMany([ + { name: "Thai Curry Palace", cuisine: "Thai", features: ["Private Dining"] }, + { name: "Italian Bistro", cuisine: "Italian", features: ["Outdoor Seating"] }, + { name: "Mexican Grill", cuisine: "Mexican", features: ["Takeout"] } + ]); + +**Query example** + + + db.restaurants.find({ name: { $eq: "Thai Curry Palace" } }); + +**Output** + + + { "_id" : ObjectId("68ee586f916df9d39f3d9414"), "name" : "Thai Curry Palace", "cuisine" : "Thai", "features" : [ "Private Dining" ] } + +## Code examples + +To view a code example for using the `$eq` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findByName(name) { + 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 collection = db.collection('restaurants'); + + const results = await collection.find({ name: { $eq: name } }).toArray(); + console.log(results); + + await client.close(); + } + + findByName("Thai Curry Palace"); + +Python + + + + from pymongo import MongoClient + + def find_by_name(name): + client = MongoClient("mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false") + db = client["test"] + collection = db["restaurants"] + + results = list(collection.find({ "name": { "$eq": name } })) + print(results) + + client.close() + + find_by_name("Thai Curry Palace") + + **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) + +$elemMatch + +$exists + +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.