AWS documentdb documentation change
Summary
Added new documentation page for the $pullAll operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds routine documentation for a MongoDB operator ($pullAll) with standard usage examples. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for database connections, but this is not the primary focus of the documentation. There is no evidence of addressing a specific security vulnerability, weakness, or incident.
Diff
diff --git a/documentdb/latest/developerguide/pullAll.md b/documentdb/latest/developerguide/pullAll.md index 8b1378917..9e73879fe 100644 --- a//documentdb/latest/developerguide/pullAll.md +++ b//documentdb/latest/developerguide/pullAll.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#pullAll "Open PDF") @@ -1,0 +3,132 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $pullAll + +The `$pullAll` operator in Amazon DocumentDB is used to remove all instances of the specified values from an array field. This is particularly useful when you need to remove multiple elements from an array in a single operation. + +**Parameters** + + * `field`: The name of the array field from which to remove the elements. + + * `value`: An array of values to remove from the array field. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$pullAll` operator to remove multiple elements from an array field. + +**Create sample documents** + + + db.restaurants.insert([ + { + "name": "Taj Mahal", + "cuisine": "Indian", + "features": ["Private Dining", "Live Music"] + }, + { + "name": "Golden Palace", + "cuisine": "Chinese", + "features": ["Private Dining", "Takeout"] + }, + { + "name": "Olive Garden", + "cuisine": "Italian", + "features": ["Private Dining", "Outdoor Seating"] + } + ]) + +**Query example** + + + db.restaurants.update( + { "name": "Taj Mahal" }, + { $pullAll: { "features": ["Private Dining", "Live Music"] } } + ) + +**Output** + + + { + "name": "Taj Mahal", + "cuisine": "Indian", + "features": [] + } + +## Code examples + +To view a code example for using the `$pullAll` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function main() { + 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('restaurants'); + + await collection.updateMany( + { "name": "Taj Mahal" }, + { $pullAll: { "features": ["Private Dining", "Live Music"] } } + ); + + const updatedDocument = await collection.findOne({ "name": "Taj Mahal" }); + console.log(updatedDocument); + + await client.close(); + } + + main(); + +Python + + + + from pymongo import MongoClient + + def main(): + 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['restaurants'] + + collection.update_many( + {"name": "Taj Mahal"}, + {"$pullAll": {"features": ["Private Dining", "Live Music"]}} + ) + + updated_document = collection.find_one({"name": "Taj Mahal"}) + print(updated_document) + + client.close() + + if __name__ == '__main__': + main() + + **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) + +$pull + +$push + +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.