AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/add.md

Summary

Added new documentation page for the $add operator in Amazon DocumentDB, including description, parameters, MongoDB shell example, and code examples in Node.js and Python with secure connection strings

Security assessment

This change adds documentation for a database operator ($add) with code examples that include secure connection parameters (tls=true, tlsCAFile=global-bundle.pem). While it demonstrates security best practices for TLS connections, it does not address a specific security vulnerability or incident. The documentation promotes secure defaults but is primarily about a database operator feature.

Diff

diff --git a/documentdb/latest/developerguide/add.md b/documentdb/latest/developerguide/add.md
index 8b1378917..842b0e9dd 100644
--- a//documentdb/latest/developerguide/add.md
+++ b//documentdb/latest/developerguide/add.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#add "Open PDF")
@@ -1,0 +3,122 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $add
+
+The `$add` operator in Amazon DocumentDB is used to add numbers or dates together. It can be used to perform arithmetic operations on numeric fields or to perform date arithmetic by adding a number of time units to a date field.
+
+**Parameters**
+
+  * `expression1`: The first number or date to add.
+
+  * `expression2`: The second number or date to add.
+
+  * `expression3`: (optional) Additional numbers or dates to add.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$add` operator to add two numbers together.
+
+**Create sample documents**
+    
+    
+    db.numbers.insertMany([
+      { _id: 1, a: 5, b: 3 },
+      { _id: 2, a: 10, b: 7 },
+      { _id: 3, a: 2, b: 8 }
+    ]);
+
+**Query example**
+    
+    
+    db.numbers.aggregate([
+      { $project: {
+        _id: 1,
+        sum: { $add: ["$a", "$b"] }
+      }}
+    ])
+
+**Output**
+    
+    
+    [
+      { "_id" : 1, "sum" : 8 },
+      { "_id" : 2, "sum" : 17 },
+      { "_id" : 3, "sum" : 10 }
+    ]
+
+In this example, the `$add` operator is used to add the values of the `a` and `b` fields for each document and store the result in the `sum` field.
+
+## Code examples
+
+To view a code example for using the `$add` 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,
+          sum: { $add: ['$a', '$b'] }
+        }}
+      ]).toArray();
+    
+      console.log(result);
+      client.close();
+    }
+    
+    example();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    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,
+            'sum': { '$add': ['$a', '$b'] }
+        }}
+    ]))
+    
+    print(result)
+    client.close()
+
+![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)
+
+$abs
+
+$addToSet
+
+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.