AWS documentdb documentation change
Summary
Added new documentation page for the $isoWeekYear operator in Amazon DocumentDB, including description, parameters, MongoDB Shell example, and code examples in Node.js and Python
Security assessment
This change adds documentation for a date/time operator ($isoWeekYear) that returns ISO 8601 week year numbers. The content is purely functional documentation about a specific MongoDB-compatible operator in DocumentDB. The code examples show standard connection strings with TLS parameters (tls=true, tlsCAFile=global-bundle.pem) which are existing security best practices, not new security features. There is no evidence of addressing a security vulnerability, weakness, or incident.
Diff
diff --git a/documentdb/latest/developerguide/isoWeekYear.md b/documentdb/latest/developerguide/isoWeekYear.md index 8b1378917..fc5f261e8 100644 --- a//documentdb/latest/developerguide/isoWeekYear.md +++ b//documentdb/latest/developerguide/isoWeekYear.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#isoWeekYear "Open PDF") @@ -1,0 +3,119 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $isoWeekYear + +The `$isoWeekYear` operator in Amazon DocumentDB returns the ISO 8601 week year number for a given date. The ISO week year number differs from the Gregorian calendar year in that the week year can be different from the calendar year, especially at the start and end of the year. + +**Parameters** + + * `expression`: The date expression for which to return the ISO 8601 week year number. + + + + +## Example (MongoDB Shell) + +This example demonstrates how to use the `$isoWeekYear` operator to retrieve the ISO 8601 week year for the date field of each document in the events collection. + +**Create sample documents** + + + db.events.insertMany([ + { _id: 1, name: "Event 1", date: ISODate("2022-12-31T00:00:00Z") }, + { _id: 2, name: "Event 2", date: ISODate("2023-01-01T00:00:00Z") }, + { _id: 3, name: "Event 3", date: ISODate("2023-01-02T00:00:00Z") } + ]); + +**Query example** + + + db.events.aggregate([ + { $project: { + name: 1, + isoWeekYear: { $isoWeekYear: "$date" } + }} + ]); + +**Output** + + + [ + { "_id" : 1, "name" : "Event 1", "isoWeekYear" : 2023 }, + { "_id" : 2, "name" : "Event 2", "isoWeekYear" : 2023 }, + { "_id" : 3, "name" : "Event 3", "isoWeekYear" : 2023 } + ] + +## Code examples + +To view a code example for using the `$isoWeekYear` 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 events = db.collection('events'); + + const result = await events.aggregate([ + { $project: { + name: 1, + isoWeekYear: { $isoWeekYear: '$date' } + }} + ]).toArray(); + + console.log(result); + client.close(); + } + + example(); + +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') + db = client.test + events = db.events + + result = list(events.aggregate([ + { '$project': { + 'name': 1, + 'isoWeekYear': { '$isoWeekYear': '$date' } + }} + ])) + + 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) + +$isoWeek + +$last + +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.