AWS documentdb documentation change
Summary
Added new documentation page for the $max aggregation stage in Amazon DocumentDB, including description, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This is standard documentation for a database aggregation operator ($max) that finds the maximum value of a field across documents. The change includes code examples with TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but this is not new security documentation. There is no evidence of addressing a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/max.md b/documentdb/latest/developerguide/max.md index 8b1378917..5fb15f1b4 100644 --- a//documentdb/latest/developerguide/max.md +++ b//documentdb/latest/developerguide/max.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#max "Open PDF") @@ -1,0 +3,108 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $max + +The `$max` aggregation stage is used to return the maximum value of a specified field across all documents in a pipeline stage. This operator is useful for finding the highest value in a set of documents. + +**Parameters** + + * `expression`: The expression to use to calculate the maximum value. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$max` operator to find the maximum score in a collection of student documents. The `$group` stage groups all documents together, and the `$max` operator is used to calculate the maximum value of the `score` field across all documents. + +**Create sample documents** + + + db.students.insertMany([ + { name: "John", score: 85 }, + { name: "Jane", score: 92 }, + { name: "Bob", score: 78 }, + { name: "Alice", score: 90 } + ]) + +**Query example** + + + db.students.aggregate([ + { $group: { _id: null, maxScore: { $max: "$score" } } }, + { $project: { _id: 0, maxScore: 1 } } + ]) + +**Output** + + + [ { maxScore: 92 } ] + +## Code examples + +To view a code example for using the `$max` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findMaxScore() { + 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 students = db.collection('students'); + + const result = await students.aggregate([ + { $group: { _id: null, maxScore: { $max: "$score" } } } + ]).toArray(); + + console.log(result); + await client.close(); + } + + findMaxScore(); + +Python + + + + from pymongo import MongoClient + + def find_max_score(): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client['test'] + students = db.students + + result = list(students.aggregate([ + { "$group": { "_id": None, "maxScore": { "$max": "$score" } } } + ])) + + print(result) + client.close() + + find_max_score() + + **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) + +$match + +$meta + +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.