AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/toDouble.md

Summary

Added new documentation page for the $toDouble 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 new data type conversion operator ($toDouble) in DocumentDB. The documentation includes standard usage examples and connection strings with TLS enabled (tls=true & tlsCAFile=global-bundle.pem), which is a standard security practice for DocumentDB connections but not the primary focus of this documentation. There is no evidence this addresses a specific security vulnerability or incident.

Diff

diff --git a/documentdb/latest/developerguide/toDouble.md b/documentdb/latest/developerguide/toDouble.md
index 8b1378917..30b30aa7b 100644
--- a//documentdb/latest/developerguide/toDouble.md
+++ b//documentdb/latest/developerguide/toDouble.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#toDouble "Open PDF")
@@ -1,0 +3,130 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $toDouble
+
+New from version 4.0
+
+The `$toDouble` operator in Amazon DocumentDB is used to convert a value to a double-precision 64-bit floating-point number. This can be useful when you need to perform arithmetic operations on values that are not originally in a numeric format.
+
+**Parameters**
+
+`<expression>`: The expression to convert to a double value. This can be any valid expression that resolves to a numeric, string, or boolean value.
+
+## Example (MongoDB Shell)
+
+This example demonstrates how to use the `$toDouble` operator to convert a string value to a numeric value for the purpose of performing a mathematical calculation.
+
+**Create sample documents**
+    
+    
+    db.numbers.insertMany([
+      { _id: 1, value: "10.5" },
+      { _id: 2, value: "20.25" },
+      { _id: 3, value: "7" }
+    ])
+
+**Query example**
+    
+    
+    db.numbers.aggregate([
+      {
+        $project: {
+          _id: 1,
+          value: 1,
+          double_value: { $toDouble: "$value" },
+          double_plus_five: { $add: [{ $toDouble: "$value" }, 5] }
+        }
+      }
+    ])
+
+**Output**
+    
+    
+    [
+      { "_id" : 1, "value" : "10.5", "double_value" : 10.5, "double_plus_five" : 15.5 },
+      { "_id" : 2, "value" : "20.25", "double_value" : 20.25, "double_plus_five" : 25.25 },
+      { "_id" : 3, "value" : "7", "double_value" : 7.0, "double_plus_five" : 12.0 }
+    ]
+
+## Code examples
+
+To view a code example for using the `$toDouble` 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('numbers');
+    
+      const result = await collection.aggregate([
+        {
+          $project: {
+            _id: 1,
+            value: 1,
+            double_value: { $toDouble: "$value" },
+            double_plus_five: { $add: [{ $toDouble: "$value" }, 5] }
+          }
+        }
+      ]).toArray();
+    
+      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['numbers']
+    
+        result = list(collection.aggregate([
+            {
+                '$project': {
+                    '_id': 1,
+                    'value': 1,
+                    'double_value': { '$toDouble': '$value' },
+                    'double_plus_five': { '$add': [{ '$toDouble': '$value' }, 5] }
+                }
+            }
+        ]))
+    
+        print(result)
+        client.close()
+    
+    example()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **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)
+
+$toDecimal
+
+$toInt
+
+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.