AWS documentdb documentation change
Summary
Added new documentation page for the $min update operator in Amazon DocumentDB, including syntax, examples in MongoDB Shell, Node.js, and Python with connection examples
Security assessment
This change adds documentation for the $min update operator that conditionally updates fields when new values are lower. The code examples include standard secure connection parameters (TLS, CA file) but this is routine secure connection practice. There is no evidence this addresses a security vulnerability or weakness; it's purely functional documentation for a database operator.
Diff
diff --git a/documentdb/latest/developerguide/min-update.md b/documentdb/latest/developerguide/min-update.md index 8b1378917..e0be773b1 100644 --- a//documentdb/latest/developerguide/min-update.md +++ b//documentdb/latest/developerguide/min-update.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#min-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 + +# $min + +The `$min` update operator updates a field's value only if the specified value is less than the current field value. This operator is useful for maintaining minimum 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 `$min` operator to update the lowest recorded temperature for a weather station. + +**Create sample documents** + + + db.weather.insertMany([ + { _id: 1, station: "Station A", lowestTemp: 15 }, + { _id: 2, station: "Station B", lowestTemp: 20 }, + { _id: 3, station: "Station C", lowestTemp: 18 } + ]) + +**Update example** + + + db.weather.updateOne( + { _id: 1 }, + { $min: { lowestTemp: 12 } } + ) + +**Result** + +The `lowestTemp` field for Station A is updated to 12 because 12 is less than the current value of 15. + + + { "_id": 1, "station": "Station A", "lowestTemp": 12 } + +## Code examples + +To view a code example for using the `$min` 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('weather'); + + const result = await collection.updateOne( + { _id: 1 }, + { $min: { lowestTemp: 12 } } + ); + + 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['weather'] + + result = collection.update_one( + { '_id': 1 }, + { '$min': { 'lowestTemp': 12 } } + ) + + 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) + +$max + +$mul + +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.