AWS documentdb documentation change
Summary
Added new documentation page for the $and operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell examples, and code examples in Node.js and Python
Security assessment
This is routine documentation addition for a query operator ($and) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but this is not new security documentation - it's just showing typical connection strings. No evidence of addressing a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/and.md b/documentdb/latest/developerguide/and.md index 8b1378917..a7737f47e 100644 --- a//documentdb/latest/developerguide/and.md +++ b//documentdb/latest/developerguide/and.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#and "Open PDF") @@ -1,0 +3,123 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $and + +The `$and` operator in Amazon DocumentDB is used to combine multiple expressions and evaluate them as a single condition. It returns `true` if all the provided expressions evaluate to `true`, and `false` otherwise. This operator is useful for applying multiple criteria to a query. + +**Parameters** + + * `expression1`: A required expression that evaluates to a boolean value. + + * `expression2`: A required expression that evaluates to a boolean value. + + * `...`: Additional required expressions that evaluate to boolean values. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the use of the `$and` operator to find all documents in the "users" collection where the "age" field is greater than 18 and the "status" field is "active". + +**Create sample documents** + + + db.users.insertMany([ + { name: "John", age: 25, status: "active" }, + { name: "Jane", age: 17, status: "active" }, + { name: "Bob", age: 30, status: "inactive" }, + { name: "Alice", age: 22, status: "active" } + ]); + +**Query example** + + + db.users.find({ + $and: [ + { age: { $gt: 18 } }, + { status: "active" } + ] + }); + +**Output** + + + [ + { "_id" : ObjectId("614e3c4b63f5892e7c4e2345"), "name" : "John", "age" : 25, "status" : "active" }, + { "_id" : ObjectId("614e3c4b63f5892e7c4e2347"), "name" : "Alice", "age" : 22, "status" : "active" } + ] + +## Code examples + +To view a code example for using the `$and` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findActiveUsersOlderThan18() { + 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 = db.collection('users'); + + const activeUsersOlderThan18 = await users.find({ + $and: [ + { age: { $gt: 18 } }, + { status: 'active' } + ] + }).toArray(); + + console.log(activeUsersOlderThan18); + await client.close(); + } + + findActiveUsersOlderThan18(); + +Python + + + + from pymongo import MongoClient + + def find_active_users_older_than_18(): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client['test'] + users = db['users'] + + active_users_older_than_18 = list(users.find({ + '$and': [ + {'age': {'$gt': 18}}, + {'status': 'active'} + ] + })) + + print(active_users_older_than_18) + client.close() + + find_active_users_older_than_18() + + **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) + +$all + +$bitsAllClear + +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.