AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/inc.md

Summary

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

Security assessment

This is a routine documentation addition for a MongoDB operator ($inc) used for incrementing field values. The change includes standard code examples with connection strings that use TLS encryption (tls=true) and CA certificates, which is standard security practice but not evidence of addressing a specific security issue. No security vulnerabilities, weaknesses, or incidents are mentioned in the documentation.

Diff

diff --git a/documentdb/latest/developerguide/inc.md b/documentdb/latest/developerguide/inc.md
index 8b1378917..f0c10e772 100644
--- a//documentdb/latest/developerguide/inc.md
+++ b//documentdb/latest/developerguide/inc.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#inc "Open PDF")
@@ -1,0 +3,111 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $inc
+
+The `$inc` operator is used to increment the value of a field by a specified amount. It is used to update a numeric field, such as a counter or a rating, without having to retrieve the current value, calculate the new value, and then update the field.
+
+**Parameters**
+
+  * `field`: The name of the field to increment.
+
+  * `amount`: The amount by which to increment the field. This can be a positive or negative value.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$inc` operator to increment the `age` field of a document.
+
+**Create sample documents**
+    
+    
+    db.users.insertOne({_id: 123, name: "John Doe", age: 30})
+
+**Query example**
+    
+    
+    db.users.updateOne({_id: 123}, {$inc: {age: 1}})
+
+**View updated document**
+    
+    
+    db.users.findOne({_id: 123})
+
+**Output**
+    
+    
+    { "_id" : 123, "name" : "John Doe", "age" : 31 }
+
+## Code examples
+
+To view a code example for using the `$inc` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function updateWithInc() {
+      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('users');
+    
+      const result = await collection.updateOne(
+        { _id: 123 },
+        { $inc: { age: 1 } }
+      );
+    
+      console.log(result);
+    
+      await client.close();
+    }
+    
+    updateWithInc();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def update_with_inc():
+        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['users']
+    
+        result = collection.update_one(
+            {'_id': 123},
+            {'$inc': {'age': 1}}
+        )
+    
+        print(result.modified_count)
+    
+        client.close()
+    
+    update_with_inc()
+
+![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)
+
+$each
+
+$max
+
+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.