AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/dollarIdentifier-update.md

Summary

Added new documentation page for the $[<identifier>] filtered positional operator with examples in MongoDB Shell, Node.js, and Python

Security assessment

This change adds documentation for a MongoDB update operator feature (filtered positional operator) with standard usage examples. The code examples include TLS connection parameters which are standard security practices for database connections, but this is not addressing a specific security vulnerability or weakness. The change appears to be routine feature documentation.

Diff

diff --git a/documentdb/latest/developerguide/dollarIdentifier-update.md b/documentdb/latest/developerguide/dollarIdentifier-update.md
index 8b1378917..fd673fc6c 100644
--- a//documentdb/latest/developerguide/dollarIdentifier-update.md
+++ b//documentdb/latest/developerguide/dollarIdentifier-update.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#dollarIdentifier-update "Open PDF")
@@ -1,0 +3,130 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $[<identifier>]
+
+The `$[<identifier>]` filtered positional operator updates all array elements that match the specified filter conditions. It is used with the `arrayFilters` option to selectively update array elements.
+
+**Parameters**
+
+  * `field.$[identifier]`: The array field with the filtered positional operator.
+
+  * `arrayFilters`: An array of filter conditions that determine which elements to update.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates using the `$[<identifier>]` operator to update specific array elements based on a condition.
+
+**Create sample documents**
+    
+    
+    db.students.insertOne({
+      _id: 1,
+      name: "Alice",
+      grades: [
+        { subject: "Math", score: 85 },
+        { subject: "Science", score: 92 },
+        { subject: "History", score: 78 }
+      ]
+    });
+
+**Query example**
+    
+    
+    db.students.updateOne(
+      { _id: 1 },
+      { $inc: { "grades.$[elem].score": 5 } },
+      { arrayFilters: [{ "elem.score": { $gte: 80 } }] }
+    );
+
+**Output**
+    
+    
+    {
+      "_id" : 1,
+      "name" : "Alice",
+      "grades" : [
+        { "subject" : "Math", "score" : 90 },
+        { "subject" : "Science", "score" : 97 },
+        { "subject" : "History", "score" : 78 }
+      ]
+    }
+
+## Code examples
+
+To view a code example for using the `$[<identifier>]` operator, 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('students');
+    
+      await collection.updateOne(
+        { _id: 1 },
+        { $inc: { "grades.$[elem].score": 5 } },
+        { arrayFilters: [{ "elem.score": { $gte: 80 } }] }
+      );
+    
+      const updatedDocument = await collection.findOne({ _id: 1 });
+      console.log(updatedDocument);
+    
+      await 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.students
+    
+        collection.update_one(
+            {'_id': 1},
+            {'$inc': {'grades.$[elem].score': 5}},
+            array_filters=[{'elem.score': {'$gte': 80}}]
+        )
+    
+        updated_document = collection.find_one({'_id': 1})
+        print(updated_document)
+    
+        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)
+
+$[]
+
+$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.