AWS documentdb documentation change
Summary
Entire documentation page for the $arrayToObject operator has been removed, including all examples, parameters, and code samples in Node.js and Python.
Security assessment
This change removes documentation content entirely without any indication of security vulnerabilities, patches, or security-related updates. The removed content was purely about the functionality of the $arrayToObject operator with no security warnings or security-related context. This appears to be a routine documentation cleanup or restructuring.
Diff
diff --git a/documentdb/latest/developerguide/arrayToObject.md b/documentdb/latest/developerguide/arrayToObject.md index 5e4e45483..8b1378917 100644 --- a//documentdb/latest/developerguide/arrayToObject.md +++ b//documentdb/latest/developerguide/arrayToObject.md @@ -1 +0,0 @@ -[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#arrayToObject "Open PDF") @@ -3,115 +1,0 @@ -[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) - -Example (MongoDB Shell)Code examples - -# $arrayToObject - -The `$arrayToObject` operator in Amazon DocumentDB is the reverse of the `$objectToArray` operator. It takes an array of key-value pair documents and converts it into a single document. This is particularly useful when you need to convert an array of key-value pairs back into an object or document structure. - -**Parameters** - - * `array expression`: An expression that resolves to an array. The array elements must be documents with two fields: `k` (the key) and `v` (the value). - - - - -## Example (MongoDB Shell) - -The example below demonstrates how to use `$arrayToObject` to convert an array of key-value pairs back into a document. - -**Create sample documents** - - - db.videos.insertMany([ - { "_id": 1, "name": "Live Soft", "inventory": { "Des Moines": 1000, "Ames": 500 } }, - { "_id": 2, "name": "Top Pilot", "inventory": { "Mason City": 250, "Des Moines": 1000 } }, - { "_id": 3, "name": "Romancing the Rock", "inventory": { "Mason City": 250, "Ames": 500 } }, - { "_id": 4, "name": "Bravemind", "inventory": { "Mason City": 250, "Des Moines": 1000, "Ames": 500 } } - ]); - -**Query example** - - - db.videos.aggregate([ - { $project: { name: 1, videos: { $objectToArray: "$inventory" } } }, - { $project: { name: 1, inventory: { $arrayToObject: "$videos" } } } - ]); - -**Output** - - - { "_id" : 1, "name" : "Live Soft", "inventory" : { "Des Moines" : 1000, "Ames" : 500 } } - { "_id" : 2, "name" : "Top Pilot", "inventory" : { "Mason City" : 250, "Des Moines" : 1000 } } - { "_id" : 3, "name" : "Romancing the Rock", "inventory" : { "Mason City" : 250, "Ames" : 500 } } - { "_id" : 4, "name" : "Bravemind", "inventory" : { "Mason City" : 250, "Des Moines" : 1000, "Ames" : 500 } } - -In this example, the `$objectToArray` operator is used to convert the `inventory` object into an array of key-value pairs. The `$arrayToObject` operator is then used to convert the array back into a document, restoring the original object structure. - -## Code examples - -To view a code example for using the `$arrayToObject` 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('videos'); - - const result = await collection.aggregate([ - { $project: { name: 1, videos: { $objectToArray: '$inventory' } } }, - { $project: { name: 1, inventory: { $arrayToObject: '$videos' } } } - ]).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'] - collection = db['videos'] - - result = list(collection.aggregate([ - { '$project': { 'name': 1, 'videos': { '$objectToArray': '$inventory' } } }, - { '$project': { 'name': 1, 'inventory': { '$arrayToObject': '$videos' } } } - ])) - - 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) - -$arrayElemAt - -$avg - -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.