AWS documentdb documentation change
Summary
Added documentation for the $floor operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds routine documentation for a mathematical operator ($floor) in Amazon DocumentDB. The content includes standard usage examples and connection strings with TLS parameters, but there is no evidence of addressing a security vulnerability or weakness. The TLS parameters in code examples are standard security practices for database connections, not new security documentation.
Diff
diff --git a/documentdb/latest/developerguide/floor.md b/documentdb/latest/developerguide/floor.md index 8b1378917..cbe4e14da 100644 --- a//documentdb/latest/developerguide/floor.md +++ b//documentdb/latest/developerguide/floor.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#floor "Open PDF") @@ -1,0 +3,124 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $floor + +New from version 4.0. + +The `$floor` operator in Amazon DocumentDB returns the largest integer that is less than or equal to the specified number. This operator is useful for rounding down numeric values. + +**Parameters** + + * `expression`: The numeric expression to round down. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the use of the `$floor` operator to round a decimal value down to the nearest integer. + +**Create sample documents** + + + db.numbers.insertOne({ value: 3.14 }); + +**Query example** + + + db.numbers.aggregate([ + { $project: { _id: 0, floored: { $floor: "$value" } } } + ]); + +**Output** + + + { "floored" : 3 } + +## Code examples + +To view a code example for using the `$floor` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function example() { + const uri = 'mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'; + const client = new MongoClient(uri); + + try { + await client.connect(); + + const db = client.db('test'); + const collection = db.collection('numbers'); + + const result = await collection.aggregate([ + { $project: { _id: 0, floored: { $floor: "$value" } } } + ]).toArray(); + + console.log(result); + + } catch (error) { + console.error('Error:', error); + } finally { + await client.close(); + } + } + + example(); + +Python + + + + from pymongo import MongoClient + from pprint import pprint + + 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': 0, 'floored': { '$floor': '$value' }}} + ])) + + pprint(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) + +$first + +$geoNear + +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.