AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/divide.md

Summary

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

Security assessment

This change adds routine documentation for a mathematical operator ($divide) in DocumentDB's aggregation pipeline. The content focuses on functionality usage examples and does not mention any security vulnerabilities, weaknesses, or incidents. The code examples include standard TLS connection parameters (tls=true, tlsCAFile) which are normal security best practices for database connections, but these are not newly introduced security features.

Diff

diff --git a/documentdb/latest/developerguide/divide.md b/documentdb/latest/developerguide/divide.md
index 8b1378917..22194dea4 100644
--- a//documentdb/latest/developerguide/divide.md
+++ b//documentdb/latest/developerguide/divide.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#divide "Open PDF")
@@ -1,0 +3,127 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $divide
+
+The `$divide` operator in the Amazon DocumentDB aggregation pipeline is used to divide one number by another. It is a useful operator for performing mathematical operations on numeric fields within your documents.
+
+**Parameters**
+
+  * `numerator`: The dividend or the number to be divided.
+
+  * `denominator`: The divisor or the number to divide by.
+
+
+
+
+## Example (MongoDB Shell)
+
+This example demonstrates how to use the `$divide` operator to calculate the hourly rate for employees based on their yearly salary and the number of working hours per year.
+
+**Create sample documents**
+    
+    
+    db.employees.insertMany([
+      { _id: 1, name: "John Doe", salary: 80000, hoursPerYear: 2080 },
+      { _id: 2, name: "Jane Smith", salary: 90000, hoursPerYear: 2080 },
+      { _id: 3, name: "Bob Johnson", salary: 75000, hoursPerYear: 2080 }
+    ]);
+
+**Query example**
+    
+    
+    db.employees.aggregate([
+      {
+        $project: {
+          name: 1,
+          hourlyRate: { $divide: ["$salary", "$hoursPerYear"] }
+        }
+      }
+    ])
+
+**Output**
+    
+    
+    [
+      { "_id" : 1, "name" : "John Doe", "hourlyRate" : 38.46153846153846 },
+      { "_id" : 2, "name" : "Jane Smith", "hourlyRate" : 43.26923076923077 },
+      { "_id" : 3, "name" : "Bob Johnson", "hourlyRate" : 36.05769230769231 }
+    ]
+
+## Code examples
+
+To view a code example for using the `$divide` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function calculateHourlyRate() {
+      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 employees = db.collection('employees');
+    
+      const result = await employees.aggregate([
+        {
+          $project: {
+            name: 1,
+            hourlyRate: { $divide: ["$salary", "$hoursPerYear"] }
+          }
+        }
+      ]).toArray();
+    
+      console.log(result);
+      client.close();
+    }
+    
+    calculateHourlyRate();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def calculate_hourly_rate():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client.mydatabase
+        employees = db.employees
+    
+        result = list(employees.aggregate([
+            {
+                '$project': {
+                    'name': 1,
+                    'hourlyRate': { '$divide': ['$salary', '$hoursPerYear'] }
+                }
+            }
+        ]))
+    
+        print(result)
+        client.close()
+    
+    calculate_hourly_rate()
+
+![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)
+
+$dayOfYear
+
+$eq
+
+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.