AWS documentdb documentation change
Summary
Added new documentation page for the $max update operator 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 update operator ($max) that updates a field only if the new value is greater than the current value. 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 - it's just including standard connection parameters in examples. There is no evidence of addressing a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/max-update.md b/documentdb/latest/developerguide/max-update.md index 8b1378917..50575a939 100644 --- a//documentdb/latest/developerguide/max-update.md +++ b//documentdb/latest/developerguide/max-update.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#max-update "Open PDF") @@ -1,0 +3,113 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $max + +The `$max` update operator updates a field's value only if the specified value is greater than the current field value. This operator is useful for maintaining maximum values across updates. + +**Parameters** + + * `field`: The field to update. + + * `value`: The value to compare with the current field value. + + + + +## Example (MongoDB Shell) + +The following example demonstrates using the `$max` operator to update the highest recorded score for a player. + +**Create sample documents** + + + db.scores.insertMany([ + { _id: 1, player: "Alice", highScore: 85 }, + { _id: 2, player: "Bob", highScore: 92 }, + { _id: 3, player: "Charlie", highScore: 78 } + ]) + +**Update example** + + + db.scores.updateOne( + { _id: 1 }, + { $max: { highScore: 95 } } + ) + +**Result** + +The `highScore` field for Alice is updated to 95 because 95 is greater than the current value of 85. + + + { "_id": 1, "player": "Alice", "highScore": 95 } + +## 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 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('scores'); + + const result = await collection.updateOne( + { _id: 1 }, + { $max: { highScore: 95 } } + ); + + 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['scores'] + + result = collection.update_one( + { '_id': 1 }, + { '$max': { 'highScore': 95 } } + ) + + 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) + +$inc + +$min + +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.