AWS documentdb documentation change
Summary
Added comprehensive documentation for the $bitsAnySet operator in Amazon DocumentDB, including syntax, parameters, examples in MongoDB Shell, Node.js, and Python, with connection examples showing TLS configuration
Security assessment
This change documents a new bitwise query operator ($bitsAnySet) for Amazon DocumentDB. While the code examples include TLS configuration parameters (tls=true, tlsCAFile=global-bundle.pem), this is standard secure connection practice rather than addressing a specific security vulnerability. The documentation primarily focuses on feature functionality rather than security fixes.
Diff
diff --git a/documentdb/latest/developerguide/bitsAnySet.md b/documentdb/latest/developerguide/bitsAnySet.md index 8b1378917..4e6d7bb7a 100644 --- a//documentdb/latest/developerguide/bitsAnySet.md +++ b//documentdb/latest/developerguide/bitsAnySet.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#bitsAnySet "Open PDF") @@ -1,0 +3,112 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $bitsAnySet + +The `$bitsAnySet` operator in Amazon DocumentDB is used to query documents where at least one bit is set to 1 in the specified bits in a field. This operator allows you to perform bitwise operations on the values stored in fields, enabling efficient querying and analysis of data with bitwise characteristics. + +**Parameters** + + * `field`: The field name to apply the bitwise operation to. + + * `value`: The numeric bitmask that specifies which bits should be checked, or a list of bits positions to be checked. A numeric bitmask can be a binary (0b...), decimal, hexadecimal (0x...), octal (0o...), or binary (BinData) form. In a list of bits positions, the position of the least significant bit is 0. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$bitsAnySet` operator to find documents where at least one bit is set in the `flags` field. + +**Create sample documents** + + + db.collection.insertMany([ + { _id: 1, flags: 0b1010 }, + { _id: 2, flags: 0b1100 }, + { _id: 3, flags: 0b0011 }, + { _id: 4, flags: 0b0100 } + ]); + +**Query example** + + + db.collection.find({ + flags: { $bitsAnySet: 0b1010 } + }) + +**Output** + + + { "_id" : 1, "flags" : 10 } + { "_id" : 2, "flags" : 12 } + { "_id" : 3, "flags" : 3 } + +The query returns the documents where at least one of the bits specified in the bitmask `0b1010` is set in the `flags` field. + +## Code examples + +To view a code example for using the `$bitsAnySet` 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('collection'); + + const result = await collection.find({ + flags: { $bitsAnySet: 0b1010 } + }).toArray(); + + console.log(result); + + await client.close(); + } + + main(); + +Python + + + + from pymongo import MongoClient + + 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.find({ + 'flags': { '$bitsAnySet': 0b1010 } + })) + + print(result) + + client.close() + + **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) + +$bitsAnyClear + +$comment + +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.