AWS documentdb documentation change
Summary
Added new documentation page for the $log10 operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell examples, and code examples in Node.js and Python
Security assessment
This change adds documentation for a mathematical operator ($log10) in Amazon DocumentDB. The content focuses on functionality and usage examples, with no mention of security vulnerabilities, patches, or security features. The code examples include standard TLS connection parameters (tls=true, tlsCAFile) which are routine security best practices for database connections, but these are not new security features being documented.
Diff
diff --git a/documentdb/latest/developerguide/log10.md b/documentdb/latest/developerguide/log10.md index 8b1378917..59790d338 100644 --- a//documentdb/latest/developerguide/log10.md +++ b//documentdb/latest/developerguide/log10.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#log10 "Open PDF") @@ -1,0 +3,148 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $log10 + +New from version 4.0. + +The `$log10` operator in Amazon DocumentDB is used to calculate the base-10 logarithm of a number. It is useful for performing logarithmic calculations on numeric fields within the aggregation pipeline. + +**Parameters** + + * `expression`: The numeric expression for which the base-10 logarithm is to be calculated. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$log10` operator to calculate the base-10 logarithm of a numeric field. + +**Create sample documents** + + + db.numbers.insertMany([ + { _id: 1, value: 1 }, + { _id: 2, value: 10 }, + { _id: 3, value: 100 }, + { _id: 4, value: 1000 } + ]); + +**Query example** + + + db.numbers.aggregate([ + { + $project: { + _id: 1, + log10Value: { $log10: "$value" } + } + } + ]); + +**Output** + + + [ + { "_id": 1, "log10Value": 0 }, + { "_id": 2, "log10Value": 1 }, + { "_id": 3, "log10Value": 2 }, + { "_id": 4, "log10Value": 3 } + ] + +## Code examples + +To view a code example for using the `$log10` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function example() { + let client; + + try { + 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('numbers'); + + const result = await collection.aggregate([ + { + $project: { + _id: 1, + log10Value: { $log10: "$value" } + } + } + ]).toArray(); + + console.log(result); + } catch (error) { + console.error("An error occurred:", error); + } finally { + if (client) { + await client.close(); + } + } + } + + example(); + +Python + + + + from pymongo import MongoClient + + def example(): + client = None + try: + 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.numbers + + result = list(collection.aggregate([ + { + '$project': { + '_id': 1, + 'log10Value': { '$log10': '$value' } + } + } + ])) + + print(result) + + except Exception as e: + print(f"An error occurred: {e}") + + finally: + if client: + 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) + +$log + +$lt + +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.