AWS documentdb documentation change
Summary
Added new documentation page for the $ne aggregation operator with examples in MongoDB Shell, Node.js, and Python
Security assessment
This change adds documentation for the $ne aggregation operator with standard code examples. The connection strings include TLS parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but this is not introducing new security documentation - it's just showing standard connection parameters. No evidence of addressing a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/ne-aggregation.md b/documentdb/latest/developerguide/ne-aggregation.md index 8b1378917..5a1fb6861 100644 --- a//documentdb/latest/developerguide/ne-aggregation.md +++ b//documentdb/latest/developerguide/ne-aggregation.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#ne-aggregation "Open PDF") @@ -1,0 +3,133 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $ne + +The `$ne` aggregation operator compares two values and returns `true` if they are not equal, otherwise returns `false`. + +**Parameters** + + * `expression1`: The first value to compare. + + * `expression2`: The second value to compare. + + + + +## Example (MongoDB Shell) + +The following example demonstrates using the `$ne` operator to identify orders with status changes. + +**Create sample documents** + + + db.orders.insertMany([ + { _id: 1, orderId: "A123", status: "shipped", expectedStatus: "shipped" }, + { _id: 2, orderId: "B456", status: "pending", expectedStatus: "shipped" }, + { _id: 3, orderId: "C789", status: "delivered", expectedStatus: "delivered" } + ]); + +**Query example** + + + db.orders.aggregate([ + { + $project: { + orderId: 1, + status: 1, + expectedStatus: 1, + needsAttention: { $ne: ["$status", "$expectedStatus"] } + } + } + ]); + +**Output** + + + [ + { _id: 1, orderId: 'A123', status: 'shipped', expectedStatus: 'shipped', needsAttention: false }, + { _id: 2, orderId: 'B456', status: 'pending', expectedStatus: 'shipped', needsAttention: true }, + { _id: 3, orderId: 'C789', status: 'delivered', expectedStatus: 'delivered', needsAttention: false } + ] + +## Code examples + +To view a code example for using the `$ne` aggregation operator, 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('orders'); + + const result = await collection.aggregate([ + { + $project: { + orderId: 1, + status: 1, + expectedStatus: 1, + needsAttention: { $ne: ["$status", "$expectedStatus"] } + } + } + ]).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['orders'] + + result = list(collection.aggregate([ + { + '$project': { + 'orderId': 1, + 'status': 1, + 'expectedStatus': 1, + 'needsAttention': { '$ne': ['$status', '$expectedStatus'] } + } + } + ])) + + 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) + +$natural + +$not + +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.