AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/DESCEND.md

Summary

Added new documentation page for the $$DESCEND operator used in the $redact aggregation pipeline stage in Amazon DocumentDB, including usage examples and code samples.

Security assessment

The change documents the $$DESCEND operator, which is part of the $redact stage used for data redaction and access control in aggregation pipelines. This is a security feature that helps control data exposure. However, there is no evidence in the diff that this change addresses a specific security vulnerability or incident; it appears to be routine feature documentation. The documentation explains how to use the operator for data filtering, which is a security-related feature.

Diff

diff --git a/documentdb/latest/developerguide/DESCEND.md b/documentdb/latest/developerguide/DESCEND.md
index 8b1378917..76270e694 100644
--- a//documentdb/latest/developerguide/DESCEND.md
+++ b//documentdb/latest/developerguide/DESCEND.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#DESCEND "Open PDF")
@@ -1,0 +3,129 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $$DESCEND
+
+The `$$DESCEND` operator in Amazon DocumentDB is a special positional array operator used within the `$redact` pipeline stage. It instructs the aggregation pipeline to descend into the current document and process all fields, regardless of their nesting level.
+
+When the `$redact` stage encounters the `$$DESCEND` operator, it will keep all the fields in the current document visible and process them further down the pipeline. This is useful when you want to selectively redact or prune certain fields based on a condition, while retaining the structure of the document.
+
+**Parameters**
+
+None.
+
+## Example (MongoDB Shell)
+
+In this example, we'll use the `$redact` stage with the `$$DESCEND` operator to selectively display documents where the `code` field is equal to "Reg".
+
+**Create sample documents**
+    
+    
+    db.patient.insertMany([
+      { "_id": 1, "code": "Emp", "patient": "John Doe", "DOB": "1/1/1980", "Hospital": "Main" },
+      { "_id": 2, "code": "Reg", "patient": "Jane Doe", "DOB": "3/27/1989", "Hospital": "Cherry Hill" },
+      { "_id": 3, "code": "Emp", "patient": "Bob Smith", "DOB": "6/15/1975", "Hospital": "Downtown" }
+    ]);
+
+**Query example**
+    
+    
+    db.patient.aggregate([
+      { $redact: {
+        $cond: {
+          if: { $eq: ["Reg", "$code"] },
+          then: "$$DESCEND",
+          else: "$$PRUNE"
+        }
+      }}
+    ]);
+
+**Output**
+    
+    
+    {
+      "_id": 2,
+      "code": "Reg",
+      "patient": "Jane Doe",
+      "DOB": "3/27/1989",
+      "Hospital": "Cherry Hill"
+    }
+
+## Code examples
+
+To view a code example for using the `$$DESCEND` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function redactPatients() {
+      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('patient');
+    
+      const result = await collection.aggregate([
+        { $redact: {
+          $cond: {
+            if: { $eq: ["Reg", "$code"] },
+            then: "$$DESCEND",
+            else: "$$PRUNE"
+          }
+        }}
+      ]).toArray();
+    
+      console.log(result);
+      client.close();
+    }
+    
+    redactPatients();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def redact_patients():
+        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.patient
+    
+        result = list(collection.aggregate([
+            { "$redact": {
+                "$cond": {
+                    "if": { "$eq": ["Reg", "$code"] },
+                    "then": "$$DESCEND",
+                    "else": "$$PRUNE"
+                }
+            }}
+        ]))
+    
+        print(result)
+        client.close()
+    
+    redact_patients()
+
+![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)
+
+Aggregation pipeline operators
+
+$$KEEP
+
+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.