AWS documentdb documentation change
Summary
Added documentation for the $second operator in Amazon DocumentDB, including examples in MongoDB Shell, Node.js, and Python
Security assessment
This change adds documentation for the $second date operator in DocumentDB. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for encrypted connections, but this is not documenting a new security feature or addressing a specific security vulnerability. The change appears to be routine feature documentation.
Diff
diff --git a/documentdb/latest/developerguide/second.md b/documentdb/latest/developerguide/second.md index 8b1378917..e293fdbc6 100644 --- a//documentdb/latest/developerguide/second.md +++ b//documentdb/latest/developerguide/second.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#second "Open PDF") @@ -1,0 +3,104 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $second + +The `$second` operator in Amazon DocumentDB extracts the seconds component from a date or timestamp. It is used to retrieve the seconds value from a date or timestamp field. + +**Parameters** + + * `expression`: The date or timestamp field to extract the seconds value from. This expression can be a field path or any valid expression that resolves to a date or timestamp. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$second` operator to extract the seconds component from a date field. + +**Create sample documents** + + + db.users.insertMany([ + { name: "John", dob: new Date("1990-05-15T12:30:45Z") }, + { name: "Jane", dob: new Date("1985-09-20T23:59:59Z") }, + { name: "Bob", dob: new Date("2000-01-01T00:00:00Z") } + ]); + +**Query example** + + + db.users.aggregate([{ $project: { name: 1, dobSeconds: { $second: "$dob" } } }]) + +**Output** + + + [ + { "_id" : ObjectId("6089a9c306a829d1f8b456a1"), "name" : "John", "dobSeconds" : 45 }, + { "_id" : ObjectId("6089a9c306a829d1f8b456a2"), "name" : "Jane", "dobSeconds" : 59 }, + { "_id" : ObjectId("6089a9c306a829d1f8b456a3"), "name" : "Bob", "dobSeconds" : 0 } + ] + +## Code examples + +To view a code example for using the `$second` 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 users = db.collection('users'); + + const result = await users.aggregate([{ $project: { name: 1, dobSeconds: { $second: '$dob' } } }]).toArray(); + console.log(result); + + await 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'] + users = db['users'] + + result = list(users.aggregate([{'$project': {'name': 1, 'dobSeconds': {'$second': '$dob'}}}])) + 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) + +$search + +$set + +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.