AWS documentdb documentation change
Summary
Added comprehensive documentation for the $minute aggregation pipeline operator in Amazon DocumentDB, including syntax, parameters, MongoDB Shell examples, and code examples in Node.js and Python
Security assessment
This change adds documentation for a date/time aggregation operator ($minute) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for database connections, but this is not new security documentation - it's just showing typical secure connection patterns. There is no evidence this addresses a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/minute.md b/documentdb/latest/developerguide/minute.md index 8b1378917..29a51c868 100644 --- a//documentdb/latest/developerguide/minute.md +++ b//documentdb/latest/developerguide/minute.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#minute "Open PDF") @@ -1,0 +3,155 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $minute + +The `$minute` aggregation pipeline stage in Amazon DocumentDB extracts the minute value from a date or timestamp field. + +This operator is useful when you need to perform date and time-based calculations or grouping within your aggregation pipeline. + +**Parameters** + + * `expression`: The date or timestamp field from which to extract the minute value. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$minute` operator to group the documents by the minute value extracted from the timestamp field and count the number of documents in each group. + +**Create sample documents** + + + db.events.insertMany([ + { timestamp: new Date("2023-04-15T10:30:25.000Z") }, + { timestamp: new Date("2023-04-15T10:30:35.000Z") }, + { timestamp: new Date("2023-04-15T10:31:05.000Z") }, + { timestamp: new Date("2023-04-15T10:31:45.000Z") }, + { timestamp: new Date("2023-04-15T10:32:15.000Z") } + ]); + +**Query example** + + + db.events.aggregate([ + { + $group: { + _id: { + minute: { $minute: "$timestamp" } + }, + count: { $count: {} } + } + }, + { $sort: { "_id.minute": 1 } } + ]); + +**Output** + + + [ + { "_id": { "minute": 30 }, "count": 2 }, + { "_id": { "minute": 31 }, "count": 2 }, + { "_id": { "minute": 32 }, "count": 1 } + ] + +## Code examples + +To view a code example for using the `$minute` 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('events'); + + await collection.insertMany([ + { timestamp: new Date("2023-04-15T10:30:25.000Z") }, + { timestamp: new Date("2023-04-15T10:30:35.000Z") }, + { timestamp: new Date("2023-04-15T10:31:05.000Z") }, + { timestamp: new Date("2023-04-15T10:31:45.000Z") }, + { timestamp: new Date("2023-04-15T10:32:15.000Z") } + ]); + + const result = await collection.aggregate([ + { + $group: { + _id: { + minute: { $minute: "$timestamp" } + }, + count: { $count: {} } + } + }, + { $sort: { "_id.minute": 1 } } + ]).toArray(); + + console.log(result); + await client.close(); + } + + example(); + +Python + + + + from pymongo import MongoClient + from datetime import datetime + + 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['events'] + + collection.insert_many([ + {'timestamp': datetime(2023, 4, 15, 10, 30, 25)}, + {'timestamp': datetime(2023, 4, 15, 10, 30, 35)}, + {'timestamp': datetime(2023, 4, 15, 10, 31, 5)}, + {'timestamp': datetime(2023, 4, 15, 10, 31, 45)}, + {'timestamp': datetime(2023, 4, 15, 10, 32, 15)} + ]) + + result = list(collection.aggregate([ + { + '$group': { + '_id': { + 'minute': {'$minute': '$timestamp'} + }, + 'count': {'$count': {}} + } + }, + {'$sort': {'_id.minute': 1}} + ])) + + print(result) + client.close() + + example() + + **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) + +$min + +$mod + +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.