AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/size.md

Summary

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

Security assessment

This change adds routine documentation for an aggregation operator ($size) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile) which are standard security practices for DocumentDB connections, but this is not new security documentation - it's standard connection string formatting. No evidence of addressing a specific security vulnerability or incident.

Diff

diff --git a/documentdb/latest/developerguide/size.md b/documentdb/latest/developerguide/size.md
index 8b1378917..44da65c69 100644
--- a//documentdb/latest/developerguide/size.md
+++ b//documentdb/latest/developerguide/size.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#size "Open PDF")
@@ -1,0 +3,127 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $size
+
+The `$size` operator is used to return the count of items within an array field. This can be used to determine the number of elements in an array stored in a document.
+
+**Parameters**
+
+  * `field`: The field path whose array size you want to return.
+
+
+
+
+## Example (MongoDB Shell)
+
+This example shows how to use the `$size` operator to return the count of teams each user is following.
+
+**Create sample documents**
+    
+    
+    db.profiles.insertMany([
+      { _id: 1, name: "John Doe", teams: ["Acme", "Widgets", "Gadgets"] },
+      { _id: 2, name: "Jane Smith", teams: ["Acme", "Gadgets"] },
+      { _id: 3, name: "Bob Johnson", teams: ["Acme", "Widgets", "Gadgets"] }
+    ]);
+
+**Query example**
+    
+    
+    db.profiles.aggregate([
+      {
+        $project: {
+          _id: 0,
+          name: 1,
+          "numberOfTeams": { $size: "$teams" }
+        }
+      }
+    ])
+
+**Output**
+    
+    
+    [
+      { name: 'John Doe', numberOfTeams: 3 },
+      { name: 'Jane Smith', numberOfTeams: 2 },
+      { name: 'Bob Johnson', numberOfTeams: 3 }
+    ]
+
+## Code examples
+
+To view a code example for using the `$size` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function main() {
+      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 profiles = db.collection('profiles');
+    
+      const result = await profiles.aggregate([
+        {
+          $project: {
+            item: 1,
+            "numberOfTeams": { $size: "$teams" }
+          }
+        }
+      ]).toArray();
+    
+      console.log(result);
+      await client.close();
+    }
+    
+    main();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def main():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client['test']
+        profiles = db.profiles
+    
+        result = list(profiles.aggregate([
+            {
+                '$project': {
+                    'item': 1,
+                    'numberOfTeams': { '$size': '$teams' }
+                }
+            }
+        ]))
+    
+        print(result)
+        client.close()
+    
+    if __name__ == "__main__":
+        main()
+
+![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)
+
+$slice
+
+$sort
+
+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.