AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/range.md

Summary

Added comprehensive documentation for the $range aggregation operator in Amazon DocumentDB, including parameters, MongoDB Shell examples, and code examples in Node.js and Python with connection details.

Security assessment

The change adds documentation for a database aggregation operator ($range) with example code that includes secure connection parameters (TLS=true, TLS CA file, readPreference settings). While the documentation demonstrates security best practices in connection strings, there is no evidence this addresses a specific security vulnerability or incident. The change primarily adds feature documentation with security-conscious examples.

Diff

diff --git a/documentdb/latest/developerguide/range.md b/documentdb/latest/developerguide/range.md
index 8b1378917..469c166c7 100644
--- a//documentdb/latest/developerguide/range.md
+++ b//documentdb/latest/developerguide/range.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#range "Open PDF")
@@ -1,0 +3,165 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $range
+
+The `$range` aggregation operator in Amazon DocumentDB is used to create an array of consecutive numbers within a specified range. This operator is particularly useful for generating sequences of numbers, such as mile markers for aid stations in a race, as demonstrated in the examples below.
+
+**Parameters**
+
+  * `start`: The starting value for the range.
+
+  * `end`: The ending value for the range.
+
+  * `step`: (optional) The step value to use when generating the range. If not provided, the default step value is 1.
+
+
+
+
+## Example (MongoDB Shell)
+
+In this example, we'll use the `$range` operator to generate the mile markers for water stations in a bicycle race.
+
+**Create sample documents**
+    
+    
+    db.races.insertMany([
+      { _id: 0, race: "STP", distance: 206 },
+      { _id: 1, race: "RSVP", distance: 160 },
+      { _id: 2, race: "Chilly Hilly", distance: 33 },
+      { _id: 3, race: "Flying Wheels", distance: 100 }
+    ]);
+
+**Query example**
+    
+    
+    db.races.aggregate([
+      {
+        $project: {
+          race: 1,
+          "waterStations": { $range: [20, "$distance", 20] }
+        }
+      }
+    ]);
+
+**Output**
+    
+    
+    [
+      {
+        _id: 0,
+        race: 'STP',
+        waterStations: [
+           20,  40,  60,  80,
+          100, 120, 140, 160,
+          180, 200
+        ]
+      },
+      {
+        _id: 1,
+        race: 'RSVP',
+        waterStations: [
+           20,  40,  60, 80,
+          100, 120, 140
+        ]
+      },
+      { _id: 2, race: 'Chilly Hilly', waterStations: [ 20 ] },
+      { _id: 3, race: 'Flying Wheels', waterStations: [ 20, 40, 60, 80 ] }
+    ]
+
+## Code examples
+
+To view a code example for using the `$range` 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');
+    
+      try {
+        await client.connect();
+        const db = client.db('test');
+        const collection = db.collection('races');
+    
+        const pipeline = [
+          {
+            $project: {
+              race: 1,
+              waterStations: { $range: [20, "$distance", 20] } 
+            }
+          }
+        ];
+    
+        const results = await collection.aggregate(pipeline).toArray();
+    
+        console.dir(results, { depth: null });
+    
+      } finally {
+        await client.close();
+      }
+    }
+    
+    example().catch(console.error);
+
+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')
+    
+      try:
+          db = client.test
+          collection = db.races
+    
+          pipeline = [
+              {
+                  "$project": {
+                      "race": 1,
+                      "waterStations": { "$range": [20, "$distance", 20] }
+                  }
+              }
+          ]
+    
+          results = collection.aggregate(pipeline)
+    
+          for doc in results:
+              print(doc)
+    
+      except Exception as e:
+          print(f"An error occurred: {e}")
+    
+      finally:
+          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)
+
+$rand
+
+$redact
+
+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.