AWS documentdb documentation change
Summary
Added new documentation page for the $setEquals operator in Amazon DocumentDB, including description, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds standard documentation for a new query operator ($setEquals) without any mention of security vulnerabilities, patches, or security features. The code examples show standard database operations with connection strings that include TLS parameters, but these are standard secure connection practices rather than new security documentation.
Diff
diff --git a/documentdb/latest/developerguide/setEquals.md b/documentdb/latest/developerguide/setEquals.md index 8b1378917..c51585f40 100644 --- a//documentdb/latest/developerguide/setEquals.md +++ b//documentdb/latest/developerguide/setEquals.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#setEquals "Open PDF") @@ -1,0 +3,133 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $setEquals + +The `$setEquals` operator in Amazon DocumentDB is used to determine if two sets are equal. It compares two arrays and returns `true` if they contain the same distinct elements, regardless of their order. + +**Parameters** + + * `expression1`: The first array to compare. + + * `expression2`: The second array to compare. + + + + +## Example (MongoDB Shell) + +The following example demonstrates the usage of the `$setEquals` operator to compare two sets of values. + +**Create sample documents** + + + db.collection.insertMany([ + { _id: 1, fruits: ["apple", "banana", "cherry"] }, + { _id: 2, fruits: ["banana", "apple", "cherry"] }, + { _id: 3, fruits: ["apple", "banana", "orange"] } + ]) + +**Query example** + + + db.collection.find({ + $expr: { + $setEquals: ["$fruits", ["apple", "banana", "cherry"]] + } + }) + +**Output** + + + { "_id" : 1, "fruits" : [ "apple", "banana", "cherry" ] } + { "_id" : 2, "fruits" : [ "banana", "apple", "cherry" ] } + +The query uses the `$setEquals` operator to compare the `fruits` field of each document with the array `["apple", "banana", "cherry"]`. The documents where the `fruits` field is equal to the comparison array are returned. + +## Code examples + +To view a code example for using the `$setEquals` 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('mycollection'); + + // Insert sample documents + await collection.insertMany([ + { _id: 1, fruits: ["apple", "banana", "cherry"] }, + { _id: 2, fruits: ["banana", "apple", "cherry"] }, + { _id: 3, fruits: ["apple", "banana", "orange"] } + ]); + + // Query using $setEquals + const result = await collection.find({ + $expr: { + $setEquals: ["$fruits", ["apple", "banana", "cherry"]] + } + }).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['mycollection'] + + # Insert sample documents + collection.insert_many([ + {"_id": 1, "fruits": ["apple", "banana", "cherry"]}, + {"_id": 2, "fruits": ["banana", "apple", "cherry"]}, + {"_id": 3, "fruits": ["apple", "banana", "orange"]} + ]) + + # Query using $setEquals + result = list(collection.find({ + "$expr": { + "$setEquals": ["$fruits", ["apple", "banana", "cherry"]] + } + })) + + 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) + +$setDifference + +$setIntersection + +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.