AWS documentdb documentation change
Summary
Added new documentation page for the $sqrt operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds documentation for a mathematical operator ($sqrt) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile) which are standard security practices for DocumentDB connections, but these are not new security features - they're standard connection parameters that were likely already documented elsewhere. There is no evidence this addresses a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/sqrt.md b/documentdb/latest/developerguide/sqrt.md index 8b1378917..c54810149 100644 --- a//documentdb/latest/developerguide/sqrt.md +++ b//documentdb/latest/developerguide/sqrt.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#sqrt "Open PDF") @@ -1,0 +3,147 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $sqrt + +New from version 4.0. + +The `$sqrt` operator in Amazon DocumentDB is used to calculate the square root of a number. + +**Parameters** + + * `expression`: The argument can be any valid expression as long as it resolves to a non-negative number. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the usage of the `$sqrt` operator to calculate the square root of a number. + +**Create sample documents** + + + db.numbers.insertMany([ + { "_id": 1, "number": 16 }, + { "_id": 2, "number": 36 }, + { "_id": 3, "number": 64 } + ]); + +**Query example** + + + db.numbers.aggregate([ + { $project: { + "_id": 1, + "square_root": { $sqrt: "$number" } + }} + ]); + +**Output** + + + [ + { _id: 1, square_root: 4 }, + { _id: 2, square_root: 6 }, + { _id: 3, square_root: 8 } + ] + +## Code examples + +To view a code example for using the `$sqrt` 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'); + + try { + await client.connect(); + + const db = client.db('test'); + const collection = db.collection('numbers'); + + const pipeline = [ + { + $project: { + _id: 1, + square_root: { $sqrt: '$number' } + } + } + ]; + + const results = await collection.aggregate(pipeline).toArray(); + + console.dir(results, { depth: null }); + + } finally { + await client.close(); + } + } + + example().catch(console.error); + +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') + + try: + db = client.test + collection = db.numbers + + pipeline = [ + { + "$project": { + "_id": 1, + "square_root": { + "$sqrt": "$number" + } + } + } + ] + + results = collection.aggregate(pipeline) + + for doc in results: + print(doc) + + except Exception as e: + print(f"An error occurred: {e}") + + finally: + 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) + +$split + +$strLenBytes + +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.