AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/currentDate.md

Summary

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

Security assessment

This change adds new documentation for a standard date operator. The code examples include secure connection parameters (TLS=true, tlsCAFile=global-bundle.pem) which demonstrate security best practices for connecting to DocumentDB, but there is no evidence this addresses a specific security vulnerability or incident.

Diff

diff --git a/documentdb/latest/developerguide/currentDate.md b/documentdb/latest/developerguide/currentDate.md
index 8b1378917..875995632 100644
--- a//documentdb/latest/developerguide/currentDate.md
+++ b//documentdb/latest/developerguide/currentDate.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#currentDate "Open PDF")
@@ -1,0 +3,120 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $currentDate
+
+The `$currentDate` operator is used to set the value of a field to the current date and time. This operator is useful for automatically updating a field with the current timestamp when a document is inserted or updated.
+
+**Parameters**
+
+  * `field`: The field to update with the current date and time.
+
+  * `type`: (optional) Specifies the BSON type to use for the current date. Can be either `date` or `timestamp`.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$currentDate` operator to set the `lastModified` field to the current date and time when a new document is inserted.
+
+**Create sample documents**
+    
+    
+    db.users.insert({
+      name: "John Doe",
+      email: "[email protected]"
+    })
+
+**Query example**
+    
+    
+    db.users.updateOne(
+      { name: "John Doe" },
+      { $currentDate: { lastModified: true } }
+    )
+
+**View updated document**
+    
+    
+    db.users.findOne({ name: "John Doe" })
+
+**Output**
+    
+    
+    {
+      _id: ObjectId('...'),
+      name: 'John Doe',
+      email: '[email protected]',
+      lastModified: ISODate('2025-10-25T22:50:29.963Z')
+    }
+
+## Code examples
+
+To view a code example for using the `$currentDate` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function updateUserWithCurrentDate() {
+      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 users = db.collection('users');
+    
+      await users.updateOne(
+        { name: 'John Doe' },
+        { $currentDate: { lastModified: true } }
+      );
+    
+      console.log('User updated with current date');
+      client.close();
+    }
+    
+    updateUserWithCurrentDate();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def update_user_with_current_date():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client['test']
+        users = db.users
+    
+        result = users.update_one(
+            {'name': 'John Doe'},
+            {'$currentDate': {'lastModified': True}}
+        )
+    
+        print('User updated with current date')
+        client.close()
+    
+    update_user_with_current_date()
+
+![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)
+
+$bit
+
+$each
+
+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.