AWS documentdb documentation change
Summary
Added new documentation page for the $not aggregation operator with MongoDB shell examples and code examples in Node.js and Python, including connection examples with TLS configuration.
Security assessment
The change adds documentation for a MongoDB aggregation operator ($not) with code examples that include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem). This promotes secure connection practices but does not address a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/not-aggregation.md b/documentdb/latest/developerguide/not-aggregation.md index 8b1378917..a0b49c7b5 100644 --- a//documentdb/latest/developerguide/not-aggregation.md +++ b//documentdb/latest/developerguide/not-aggregation.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#not-aggregation "Open PDF") @@ -1,0 +3,128 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $not + +The `$not` aggregation operator performs a logical NOT operation on an expression. It returns `true` if the expression evaluates to `false`, and `false` if the expression evaluates to `true`. + +**Parameters** + + * `expression`: The expression to negate. + + + + +## Example (MongoDB Shell) + +The following example demonstrates using the `$not` operator to invert boolean values. + +**Create sample documents** + + + db.users.insertMany([ + { _id: 1, name: "Alice", active: true }, + { _id: 2, name: "Bob", active: false }, + { _id: 3, name: "Charlie", active: true } + ]); + +**Query example** + + + db.users.aggregate([ + { + $project: { + name: 1, + active: 1, + inactive: { $not: ["$active"] } + } + } + ]); + +**Output** + + + [ + { _id: 1, name: 'Alice', active: true, inactive: false }, + { _id: 2, name: 'Bob', active: false, inactive: true }, + { _id: 3, name: 'Charlie', active: true, inactive: false } + ] + +## Code examples + +To view a code example for using the `$not` 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('users'); + + const result = await collection.aggregate([ + { + $project: { + name: 1, + active: 1, + inactive: { $not: ["$active"] } + } + } + ]).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['users'] + + result = list(collection.aggregate([ + { + '$project': { + 'name': 1, + 'active': 1, + 'inactive': { '$not': ['$active'] } + } + } + ])) + + 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) + +$ne + +$objectToArray + +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.