AWS documentdb documentation change
Summary
Added comprehensive documentation for the $or aggregation operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell example, and code examples in Node.js and Python with connection details
Security assessment
The change adds new documentation for a database aggregation operator ($or) with code examples that include secure connection parameters (TLS=true, tlsCAFile=global-bundle.pem). While this demonstrates security best practices for connecting to DocumentDB, there is no evidence of addressing a specific security vulnerability or incident. The documentation appears to be routine feature documentation with security-conscious examples.
Diff
diff --git a/documentdb/latest/developerguide/or-aggregation.md b/documentdb/latest/developerguide/or-aggregation.md index 8b1378917..a07a289e2 100644 --- a//documentdb/latest/developerguide/or-aggregation.md +++ b//documentdb/latest/developerguide/or-aggregation.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#or-aggregation "Open PDF") @@ -1,0 +3,146 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $or + +The `$or` aggregation operator evaluates multiple expressions and returns `true` if at least one expression evaluates to `true`. It returns `false` only if all expressions are `false`. + +**Parameters** + + * `expressions`: An array of expressions to evaluate. + + + + +## Example (MongoDB Shell) + +The following example demonstrates using the `$or` operator to check if products meet any of multiple criteria. + +**Create sample documents** + + + db.items.insertMany([ + { _id: 1, name: "Widget", price: 150, onSale: false }, + { _id: 2, name: "Gadget", price: 45, onSale: false }, + { _id: 3, name: "Tool", price: 200, onSale: true } + ]); + +**Query example** + + + db.items.aggregate([ + { + $project: { + name: 1, + price: 1, + onSale: 1, + goodDeal: { + $or: [ + { $lt: ["$price", 50] }, + { $eq: ["$onSale", true] } + ] + } + } + } + ]); + +**Output** + + + [ + { _id: 1, name: 'Widget', price: 150, onSale: false, goodDeal: false }, + { _id: 2, name: 'Gadget', price: 45, onSale: false, goodDeal: true }, + { _id: 3, name: 'Tool', price: 200, onSale: true, goodDeal: true } + ] + +## Code examples + +To view a code example for using the `$or` aggregation operator, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function example() { + 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('items'); + + const result = await collection.aggregate([ + { + $project: { + name: 1, + price: 1, + onSale: 1, + goodDeal: { + $or: [ + { $lt: ["$price", 50] }, + { $eq: ["$onSale", true] } + ] + } + } + } + ]).toArray(); + + console.log(result); + await client.close(); + } + + example(); + +Python + + + + from pymongo import MongoClient + + def example(): + 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['items'] + + result = list(collection.aggregate([ + { + '$project': { + 'name': 1, + 'price': 1, + 'onSale': 1, + 'goodDeal': { + '$or': [ + { '$lt': ['$price', 50] }, + { '$eq': ['$onSale', True] } + ] + } + } + } + ])) + + print(result) + client.close() + + example() + + **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) + +$objectToArray + +$out + +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.