AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/push.md

Summary

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

Security assessment

This change adds standard operator documentation without any mention of security vulnerabilities, patches, or security-related features. The code examples include standard TLS connection parameters but these are routine secure connection practices, not new security documentation.

Diff

diff --git a/documentdb/latest/developerguide/push.md b/documentdb/latest/developerguide/push.md
index 8b1378917..6b14bda85 100644
--- a//documentdb/latest/developerguide/push.md
+++ b//documentdb/latest/developerguide/push.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#push "Open PDF")
@@ -1,0 +3,118 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $push
+
+The `$push` operator in Amazon DocumentDB is used to add an item to an array field in a document. This operator is particularly useful when you need to append new data to an existing array without overwriting the entire array.
+
+**Parameters**
+
+  * `field`: The name of the array field to which the new element should be added.
+
+  * `value`: The value to be added to the array.
+
+  * `position`: (optional) A modifier that specifies the position in the array where the new element should be added. Supported modifiers include `$` (add to the end of the array) and `$[]` (add to the end of the array, ignoring any array filters).
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$push` operator to add new elements to an array field in a document.
+
+**Create sample documents**
+    
+    
+    db.users.insert([
+      { _id: 1, name: "John Doe", hobbies: ["reading", "swimming"] },
+      { _id: 2, name: "Jane Smith", hobbies: ["gardening", "cooking"] }
+    ])
+
+**Query example**
+    
+    
+    db.users.updateOne(
+      { _id: 1 },
+      { $push: { hobbies: "hiking" } }
+    )
+
+**Output**
+    
+    
+    {
+      "acknowledged" : true,
+      "matchedCount" : 1,
+      "modifiedCount" : 1
+    }
+
+After running the update, the document with `_id: 1` will have the `hobbies` array updated to `["reading", "swimming", "hiking"]`.
+
+## Code examples
+
+To view a code example for using the `$push` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function updateDocument() {
+      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: 1 },
+        { $push: { hobbies: "hiking" } }
+      );
+    
+      console.log(result);
+      client.close();
+    }
+    
+    updateDocument();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def update_document():
+        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': 1},
+            {'$push': {'hobbies': 'hiking'}}
+        )
+    
+        print(result.raw_result)
+        client.close()
+    
+    update_document()
+
+![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)
+
+$pullAll
+
+$rename
+
+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.