AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/project.md

Summary

Added new documentation page for the $project operator in Amazon DocumentDB, including detailed explanation, parameters, MongoDB shell examples, and code examples in Node.js and Python with connection strings.

Security assessment

This change adds routine documentation for a MongoDB aggregation operator ($project) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but this is not addressing any specific security vulnerability or incident. The change appears to be routine feature documentation.

Diff

diff --git a/documentdb/latest/developerguide/project.md b/documentdb/latest/developerguide/project.md
index 8b1378917..d170daf00 100644
--- a//documentdb/latest/developerguide/project.md
+++ b//documentdb/latest/developerguide/project.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#project "Open PDF")
@@ -1,0 +3,130 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $project
+
+The `$project` operator in Amazon DocumentDB allows you to selectively include or exclude fields from output documents, pass values to the next pipeline stage, and compute new fields from input document values.
+
+**Parameters**
+
+  * `field`: The field to include or exclude from the output documents, it can be a field path (e.g., "a.b.c").
+
+  * `1` or `true`: Includes the field in the output.
+
+  * `0` or `false`: Excludes the field from the output.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates the usage of the `$project` operator on students collection
+
+**Create sample documents**
+    
+    
+    db.students.insertMany([
+      { "_id": 1, "name": "Alejandro Rosalez", "math": 85, "science": 92, "grade": "A" },
+      { "_id": 2, "name": "Carlos Salazar", "math": 78, "science": 84, "grade": "B" },
+      { "_id": 3, "name": "Nikhil Jayashankar", "math": 95, "science": 89, "grade": "A" },
+      { "_id": 4, "name": "Shirley Rodriguez", "math": 72, "science": 76, "grade": "B" }
+      ]);
+    
+
+This query includes only the `name` and `math` fields in the output. The `_id` field is included by default unless explicitly excluded.
+    
+    
+    db.students.aggregate([
+      { $project: { "name": 1, "math": 1 } }
+    ])
+
+**Output**
+    
+    
+    { _id: 1, name: "Alejandro Rosalez", math: 85 }
+    { _id: 2, name: "Carlos Salazar", math: 78 }
+    { _id: 3, name: "Nikhil Jayashankar", math: 95 }
+    { _id: 4, name: "Shirley Rodriguez", math: 72 }
+
+This query excludes the `grade` and `_id` fields from the output, showing all other fields (`name`, `math`, `science`).
+    
+    
+    db.students.aggregate([
+      { $project: { "grade": 0, "_id": 0 } }
+    ])
+
+**Output**
+    
+    
+    { name: "Alejandro Rosalez", math: 85, science: 92 }
+    { name: "Carlos Salazar", math: 78, science: 84 }
+    { name: "Nikhil Jayashankar", math: 95, science: 89 }
+    { name: "Shirley Rodriguez", math: 72, science: 76 }
+
+## Code examples
+
+To view a code example for using the `$project` 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('students');
+    
+      const result = await collection.aggregate([
+        { $project: { "name": 1, "math": 1 } }
+      ]).toArray();
+      console.log(result);
+    
+      await 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['students']
+    
+        result = list(collection.aggregate([
+            { '$project': { 'name': 1, 'math': 1 } }
+        ]))
+        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)
+
+$push
+
+$rand
+
+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.