AWS documentdb documentation change
Summary
Added new documentation page for the $ne query operator with examples in MongoDB Shell, Node.js, and Python, including note about index support in planner version 2.0
Security assessment
This change adds documentation for the $ne query operator with standard code examples. The connection strings include TLS parameters which are standard security practices, but this is routine documentation for a query operator. No evidence of addressing a specific security vulnerability or incident. The mention of 'planner version 2.0 added index support for $ne' is a performance feature, not a security feature.
Diff
diff --git a/documentdb/latest/developerguide/ne.md b/documentdb/latest/developerguide/ne.md index 8b1378917..9f82d37f2 100644 --- a//documentdb/latest/developerguide/ne.md +++ b//documentdb/latest/developerguide/ne.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#ne "Open PDF") @@ -1,0 +3,113 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $ne + +The `$ne` operator is used to match documents where the value of a field is not equal to the specified value. It is a comparison operator that can be used in query predicates to filter documents. + +Planner version 2.0 added index support for `$ne`. + +**Parameters** + + * `field`: The field to check. + + * `value`: The value to check against. + + + + +## Example (MongoDB Shell) + +In this example, we'll find all documents in the `users` collection where the `status` field is not equal to `"active"`. + +**Create sample documents** + + + db.users.insertMany([ + { name: "John", status: "active" }, + { name: "Jane", status: "inactive" }, + { name: "Bob", status: "suspended" }, + { name: "Alice", status: "active" } + ]); + +**Query example** + + + db.users.find({ status: { $ne: "active" } }); + +**Output** + + + [ + { + _id: ObjectId('...'), + name: 'Jane', + status: 'inactive' + }, + { + _id: ObjectId('...'), + name: 'Bob', + status: 'suspended' + } + ] + +## Code examples + +To view a code example for using the `$ne` 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 users = db.collection('users'); + + const result = await users.find({ status: { $ne: 'active' } }).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'] + users = db['users'] + + result = list(users.find({ 'status': { '$ne': 'active' } })) + 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) + +$meta + +$nin + +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.