AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/unset-update.md

Summary

Added new documentation page for the $unset operator in Amazon DocumentDB, including description, parameters, MongoDB shell example, and code examples in Node.js and Python with connection details.

Security assessment

The change adds standard documentation for a database operator without mentioning any security vulnerabilities, patches, or incidents. However, the code examples include security-relevant connection parameters (TLS=true, tlsCAFile) which demonstrate secure connection practices, making this documentation about security features.

Diff

diff --git a/documentdb/latest/developerguide/unset-update.md b/documentdb/latest/developerguide/unset-update.md
index 8b1378917..5b91d8653 100644
--- a//documentdb/latest/developerguide/unset-update.md
+++ b//documentdb/latest/developerguide/unset-update.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#unset-update "Open PDF")
@@ -1,0 +3,124 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $unset
+
+The `$unset` operator in Amazon DocumentDB is used to remove a specified field from a document. When a field is removed using `$unset`, the field is deleted from the document, and the document size is reduced accordingly. This can be useful when you want to remove unnecessary data from your documents.
+
+**Parameters**
+
+  * `field`: The field to remove from the document. This can be a single field or a dotted path to a nested field.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$unset` operator to remove the `Words` field from a document in the `example` collection.
+
+**Create sample documents**
+    
+    
+    db.example.insert({
+        "DocName": "Document 1",
+        "Date": {
+            "Month": 4,
+            "Day": 18,
+            "Year": 1987,
+            "DoW": "Saturday"
+        },
+        "Words": 2482
+    })
+
+**Query example**
+    
+    
+    db.example.update(
+        { "DocName" : "Document 1" },
+        { $unset: { Words:1 } }
+    )
+
+**Output**
+    
+    
+    {
+        "DocName": "Document 1",
+        "Date": {
+            "Month": 4,
+            "Day": 18,
+            "Year": 1987,
+            "DoW": "Saturday"
+        }
+    }
+
+In this example, the `$unset` operator is used to remove the `Words` field from the document with `DocName` equal to "Document 1". The resulting document no longer contains the `Words` field.
+
+## Code examples
+
+To view a code example for using the `$unset` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function removeField() {
+      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('example');
+    
+      const result = await collection.updateOne(
+        { "DocName": "Document 1" },
+        { $unset: { "Words": 1 } }
+      );
+    
+      console.log(`Modified ${result.modifiedCount} document(s)`);
+      client.close();
+    }
+    
+    removeField();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def remove_field():
+        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['example']
+    
+        result = collection.update_one(
+            {"DocName": "Document 1"},
+            {"$unset": {"Words": 1}}
+        )
+    
+        print(f"Modified {result.modified_count} document(s)")
+        client.close()
+    
+    remove_field()
+
+![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)
+
+$sort
+
+Generative AI
+
+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.