AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/bit.md

Summary

Added comprehensive documentation for the $bit operator in Amazon DocumentDB, including parameters, MongoDB shell examples, and code examples in Node.js and Python with TLS connection details

Security assessment

This change adds documentation for the $bit operator functionality in DocumentDB. While the code examples include TLS connection parameters (tls=true, tlsCAFile), this is standard secure connection practice for DocumentDB and not indicative of addressing a specific security vulnerability. The documentation appears to be routine feature documentation without any mention of security patches, vulnerabilities, or incident responses.

Diff

diff --git a/documentdb/latest/developerguide/bit.md b/documentdb/latest/developerguide/bit.md
index 8b1378917..adc2529b4 100644
--- a//documentdb/latest/developerguide/bit.md
+++ b//documentdb/latest/developerguide/bit.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#bit "Open PDF")
@@ -1,0 +3,120 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $bit
+
+The `$bit` operator in Amazon DocumentDB allows you to perform bitwise operations on the bits of a given field. This can be useful for tasks like setting, clearing, or checking the state of individual bits within a number.
+
+**Parameters**
+
+  * `field`: The field to perform bitwise operations on.
+
+  * `and`: An integer value that is used to perform a bitwise AND operation on the field.
+
+  * `or`: An integer value that is used to perform a bitwise OR operation on the field.
+
+  * `xor`: An integer value that is used to perform a bitwise XOR operation on the field.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$bit` operator to perform bitwise operations on a numerical field.
+
+**Create sample documents**
+    
+    
+    db.numbers.insert([
+      { "_id": 1, "number": 5 },
+      { "_id": 2, "number": 12 }
+    ])
+
+**Query example**
+    
+    
+    db.numbers.update(
+      { "_id": 1 },
+      { "$bit": { "number": { "and": 3 } } }
+    )
+
+**Output**
+    
+    
+    {
+      "_id": 1,
+      "number": 1
+    }
+
+In this example, the `$bit` operator is used to perform a bitwise AND operation on the "number" field of the document with the `_id` of 1. The result is that the value of the "number" field is set to 1, which is the result of the bitwise AND operation between the original value of 5 and the value 3.
+
+## Code examples
+
+To view a code example for using the `$bit` 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('numbers');
+    
+      await collection.updateOne(
+        { "_id": 1 },
+        { "$bit": { "number": { "and": 3 } } }
+      );
+    
+      const result = await collection.findOne({ "_id": 1 });
+      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['numbers']
+    
+    collection.update_one(
+        {"_id": 1},
+        {"$bit": {"number": {"and": 3}}}
+    )
+    
+    result = collection.find_one({"_id": 1})
+    print(result)
+    
+    client.close()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **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)
+
+$addToSet
+
+$currentDate
+
+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.