AWS documentdb documentation change
Summary
Added new documentation page for the $millisecond operator in Amazon DocumentDB, including syntax, examples in MongoDB Shell, Node.js, and Python with connection examples
Security assessment
This change adds documentation for a date/time operator ($millisecond) that extracts milliseconds from date values. The code examples include secure connection parameters (TLS, CA file) but this is standard secure connection practice, not a new security feature or fix for a security issue. The documentation is purely functional and educational about using the operator.
Diff
diff --git a/documentdb/latest/developerguide/millisecond.md b/documentdb/latest/developerguide/millisecond.md index 8b1378917..3fb37eaa0 100644 --- a//documentdb/latest/developerguide/millisecond.md +++ b//documentdb/latest/developerguide/millisecond.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#millisecond "Open PDF") @@ -1,0 +3,142 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $millisecond + +The `$millisecond` operator in Amazon DocumentDB is used to extract the millisecond portion of a date value. + +**Parameters** + +None + +## Example (MongoDB Shell) + +This example demonstrates how to use the `$millisecond` operator to extract the millisecond portion of a date value. + +**Create sample documents** + + + db.events.insert([ + { + "name": "Event 1", + "timestamp": ISODate("2023-04-21T10:30:15.123Z") + }, + { + "name": "Event 2", + "timestamp": ISODate("2023-04-21T10:30:15.456Z") + }, + { + "name": "Event 3", + "timestamp": ISODate("2023-04-21T10:30:15.789Z") + } + ]) + +**Query example** + + + db.events.aggregate([ + { + $project: { + name: 1, + milliseconds: { $millisecond: "$timestamp" } + } + } + ]) + +**Output** + + + [ + { + "_id": ObjectId("644332a42054ed1b0d15f0c1"), + "name": "Event 1", + "milliseconds": 123 + }, + { + "_id": ObjectId("644332a42054ed1b0d15f0c2"), + "name": "Event 2", + "milliseconds": 456 + }, + { + "_id": ObjectId("644332a42054ed1b0d15f0c3"), + "name": "Event 3", + "milliseconds": 789 + } + ] + +## Code examples + +To view a code example for using the `$millisecond` 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 events = db.collection('events'); + + const result = await events.aggregate([ + { + $project: { + name: 1, + milliseconds: { $millisecond: '$timestamp' } + } + } + ]).toArray(); + + console.log(result); + + await client.close(); + } + + main(); + +Python + + + + from pymongo import MongoClient + + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client['test'] + events = db['events'] + + result = list(events.aggregate([ + { + '$project': { + 'name': 1, + 'milliseconds': { '$millisecond': '$timestamp' } + } + } + ])) + + print(result) + + client.close() + + **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) + +$mergeObjects + +$min + +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.