AWS documentdb documentation change
Summary
Added new documentation page for the $match pipeline stage in Amazon DocumentDB aggregation operations, including description, parameters, MongoDB Shell example, and code examples in Node.js and Python
Security assessment
This is a routine documentation addition for a MongoDB aggregation operator ($match). The change includes standard code examples with TLS connection parameters (tls=true, tlsCAFile) which are security best practices for DocumentDB connections, but these are not new security features - they're standard connection parameters. There is no evidence this addresses a specific security vulnerability, weakness, or incident.
Diff
diff --git a/documentdb/latest/developerguide/match.md b/documentdb/latest/developerguide/match.md index 8b1378917..cb4bb0b3a 100644 --- a//documentdb/latest/developerguide/match.md +++ b//documentdb/latest/developerguide/match.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#match "Open PDF") @@ -1,0 +3,117 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $match + +The `$match` pipeline stage in Amazon DocumentDB is used to filter the input documents to only those that match the specified query criteria. It is one of the most commonly used pipeline stages in aggregation operations. The `$match` stage is applied before any other pipeline stages, allowing you to efficiently reduce the number of documents that need to be processed by the subsequent stages. + +**Parameters** + + * `query`: A document that expresses the selection criteria for the operation. The query document uses the same syntax as the `find()` method. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the use of the `$match` stage to filter documents based on a specific field value. + +**Create sample documents** + + + db.collection.insertMany([ + { _id: 1, name: "John", age: 25, city: "New York" }, + { _id: 2, name: "Jane", age: 30, city: "Los Angeles" }, + { _id: 3, name: "Bob", age: 35, city: "Chicago" }, + { _id: 4, name: "Alice", age: 40, city: "Miami" } + ]); + +**Query example** + + + db.collection.aggregate([ + { $match: { age: { $gt: 30 } } }, + { $project: { _id: 1, name: 1, city: 1 } } + ]); + +**Output** + + + [ + { "_id": 3, "name": "Bob", "city": "Chicago" }, + { "_id": 4, "name": "Alice", "city": "Miami" } + ] + +The `$match` stage filters the documents to include only those where the `age` field is greater than 30. + +## Code examples + +To view a code example for using the `$match` 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('collection'); + + const result = await collection.aggregate([ + { $match: { age: { $gt: 30 } } }, + { $project: { _id: 1, name: 1, city: 1 } } + ]).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['collection'] + + result = list(collection.aggregate([ + { '$match': { 'age': { '$gt': 30 } } }, + { '$project': { '_id': 1, 'name': 1, 'city': 1 } } + ])) + + 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) + +$map + +$max + +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.