AWS documentdb documentation change
Summary
Added new documentation page for the $isArray 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 query operator ($isArray) used to check if a field is an array. There is no evidence of security vulnerability fixes, security patches, or security incident references. The change appears to be routine feature documentation addition. The code examples include standard TLS connection parameters but these are standard security practices for DocumentDB connections, not new security documentation.
Diff
diff --git a/documentdb/latest/developerguide/isArray.md b/documentdb/latest/developerguide/isArray.md index 8b1378917..78a6c5871 100644 --- a//documentdb/latest/developerguide/isArray.md +++ b//documentdb/latest/developerguide/isArray.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#isArray "Open PDF") @@ -1,0 +3,159 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $isArray + +The `$isArray` operator in Amazon DocumentDB is used to check if a field in a document is an array. This operator can be useful in aggregation pipelines and conditional expressions to handle array-type fields. + +**Parameters** + + * `field`: The field path to check if it is an array. + + + + +## Example (MongoDB Shell) + +This example demonstrates how to use the `$isArray` operator to identify documents where the "inventory" field is an array. + +**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": [{"location": "Mason City", "count": 250}, {"location": "Des Moines", "count": 1000}, {"location": "Ames", "count": 500}]} + ]); + +**Query example** + + + db.videos.aggregate([ + { + $match: { + $isArray: "$inventory" + } + }, + { + $project: { + _id: 1, + name: 1, + "inventory.location": 1, + "inventory.count": 1 + } + } + ]).pretty(); + +**Output** + + + { + "_id": 4, + "name": "Bravemind", + "inventory": [ + { + "location": "Mason City", + "count": 250 + }, + { + "location": "Des Moines", + "count": 1000 + }, + { + "location": "Ames", + "count": 500 + } + ] + } + +## Code examples + +To view a code example for using the `$isArray` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function run() { + 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([ + { + $match: { + $isArray: '$inventory' + } + }, + { + $project: { + _id: 1, + name: 1, + "inventory.location": 1, + "inventory.count": 1 + } + } + ]).toArray(); + + console.log(result); + + await client.close(); + } + + run(); + +Python + + + + from pymongo import MongoClient + + 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([ + { + '$match': { + '$isArray': '$inventory' + } + }, + { + '$project': { + '_id': 1, + 'name': 1, + 'inventory.location': 1, + 'inventory.count': 1 + } + } + ])) + + print(result) + + client.close() + + **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) + +$indexStats + +$isoDayOfWeek + +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.