AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/zip.md

Summary

Added comprehensive documentation for the $zip operator in Amazon DocumentDB, including syntax, parameters, examples in MongoDB Shell, Node.js, and Python, with connection examples showing TLS configuration

Security assessment

This change adds documentation for a new database operator ($zip) for combining arrays. While the code examples include TLS connection parameters (tls=true, tlsCAFile), this is standard secure connection practice for DocumentDB and not indicative of addressing a specific security vulnerability. The change appears to be routine feature documentation without evidence of addressing a security incident or vulnerability.

Diff

diff --git a/documentdb/latest/developerguide/zip.md b/documentdb/latest/developerguide/zip.md
index 8b1378917..0a25a0569 100644
--- a//documentdb/latest/developerguide/zip.md
+++ b//documentdb/latest/developerguide/zip.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#zip "Open PDF")
@@ -1,0 +3,173 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $zip
+
+The `$zip` operator in Amazon DocumentDB allows you to combine multiple arrays into a single array of tuples (key-value pairs). This is useful when you need to create new documents or objects by combining data from different sources or arrays within a document.
+
+**Parameters**
+
+  * `inputs`: An array of expressions that resolve to arrays. These arrays will be combined into a single array of tuples.
+
+  * `useLongestLength`: (optional) If `true`, the output array will have the length of the longest input array, padding shorter arrays with `null` values. If `false`, the output array will have the length of the shortest input array.
+
+  * `defaults`: (optional) An array of default values to use for the tuples if the corresponding input array is shorter than the longest input array and `useLongestLength` is `true`.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$zip` operator to combine two arrays into a single array of tuples.
+
+**Create sample documents**
+    
+    
+    db.grades.insert([
+      {
+        "_id": 1,
+        "name": "John",
+        "scores": [90, 85, 92],
+        "classes": ["Math", "English", "Science"]
+      },
+      {
+        "_id": 2,
+        "name": "Jane",
+        "scores": [88, 91, 90, 85],
+        "classes": ["Math", "English", "Science", "History"]
+      }
+    ])
+
+**Query example**
+    
+    
+    db.grades.aggregate([
+      {
+        $project: {
+          "name": 1,
+          "scoredClasses": {
+            $zip: {
+              inputs: ["$scores", "$classes"],
+              useLongestLength: true,
+              defaults: [null, null]
+            }
+          }
+        }
+      }
+    ])
+
+**Output**
+    
+    
+    [
+      {
+        "_id": 1,
+        "name": "John",
+        "scoredClasses": [
+          [90, "Math"],
+          [85, "English"],
+          [92, "Science"],
+          [null, null]
+        ]
+      },
+      {
+        "_id": 2,
+        "name": "Jane",
+        "scoredClasses": [
+          [88, "Math"],
+          [91, "English"],
+          [90, "Science"],
+          [85, "History"]
+        ]
+      }
+    ]
+
+## Code examples
+
+To view a code example for using the `$zip` 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('grades');
+    
+      const result = await collection.aggregate([
+        {
+          $project: {
+            "name": 1,
+            "scoredClasses": {
+              $zip: {
+                inputs: ["$scores", "$classes"],
+                useLongestLength: true,
+                defaults: [null, null]
+              }
+            }
+          }
+        }
+      ]).toArray();
+    
+      console.log(result);
+      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['grades']
+    
+        result = list(collection.aggregate([
+            {
+                '$project': {
+                    'name': 1,
+                    'scoredClasses': {
+                        '$zip': {
+                            'inputs': ['$scores', '$classes'],
+                            'useLongestLength': True,
+                            'defaults': [None, None]
+                        }
+                    }
+                }
+            }
+        ]))
+    
+        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)
+
+$year
+
+Geospatial
+
+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.