AWS documentdb documentation change
Summary
Added new documentation page for the $reverseArray operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds documentation for a new database operator ($reverseArray) that reverses array elements. There is no evidence of security vulnerability fixes, security patches, or security incident remediation. The change is purely functional documentation for a database feature. The code examples include standard TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security best practices for DocumentDB connections, but these are not new security features being documented - they are standard connection parameters shown in examples.
Diff
diff --git a/documentdb/latest/developerguide/reverseArray.md b/documentdb/latest/developerguide/reverseArray.md index 8b1378917..22e4469b4 100644 --- a//documentdb/latest/developerguide/reverseArray.md +++ b//documentdb/latest/developerguide/reverseArray.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#reverseArray "Open PDF") @@ -1,0 +3,135 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $reverseArray + +The `$reverseArray` operator in Amazon DocumentDB is used to reverse the elements of an array in the specified order. This operator is useful when you need to reorder the elements of an array in the reverse direction. + +**Parameters** + + * `expression`: The array expression to reverse. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$reverseArray` operator to reverse the order of elements in an array. + +**Create sample documents** + + + db.miles.insertMany([ + { "_id" : 1, "member_since" : ISODate("1987-01-01T00:00:00Z"), "credit_card" : false, "flight_miles" : [ 1205, 2560, 880 ]}, + { "_id" : 2, "member_since" : ISODate("1982-01-01T00:00:00Z"), "credit_card" : true, "flight_miles" : [ 1205, 2560, 890, 2780]}, + { "_id" : 3, "member_since" : ISODate("1999-01-01T00:00:00Z"), "credit_card" : true, "flight_miles" : [ 1205, 880]} + ]); + +**Query example** + + + db.miles.aggregate([ + { + $project: { + _id: 1, + member_since: 1, + credit_card: 1, + reversed_flight_miles: { $reverseArray: "$flight_miles" } + } + } + ]); + +**Output** + + + { "_id" : 1, "member_since" : ISODate("1987-01-01T00:00:00Z"), "credit_card" : false, "reversed_flight_miles" : [ 880, 2560, 1205 ] } + { "_id" : 2, "member_since" : ISODate("1982-01-01T00:00:00Z"), "credit_card" : true, "reversed_flight_miles" : [ 2780, 890, 2560, 1205 ] } + { "_id" : 3, "member_since" : ISODate("1999-01-01T00:00:00Z"), "credit_card" : true, "reversed_flight_miles" : [ 880, 1205 ] } + +In this example, the `$reverseArray` operator is used to reverse the order of the `flight_miles` array. The resulting `reversed_flight_miles` field in the output shows the elements of the array in the reversed order. + +## Code examples + +To view a code example for using the `$reverseArray` command, choose the tab for the language that you want to use: + +Node.js + + +Here's an example of using the `$reverseArray` operator in a Node.js application: + + + const { MongoClient } = require('mongodb'); + + async function reverseArray() { + 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('miles'); + + const result = await collection.aggregate([ + { + $project: { + _id: 1, + member_since: 1, + credit_card: 1, + reversed_flight_miles: { $reverseArray: '$flight_miles' } + } + } + ]).toArray(); + + console.log(result); + client.close(); + } + + reverseArray(); + +Python + + +Here's an example of using the `$reverseArray` operator in a Python application: + + + from pymongo import MongoClient + + def reverse_array(): + 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.miles + + result = list(collection.aggregate([ + { + '$project': { + '_id': 1, + 'member_since': 1, + 'credit_card': 1, + 'reversed_flight_miles': { '$reverseArray': '$flight_miles' } + } + } + ])) + + print(result) + client.close() + + reverse_array() + + **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) + +$replaceWith + +$rtrim + +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.