AWS documentdb documentation change
Summary
Added new documentation page for the $nin operator in Amazon DocumentDB, including syntax, parameters, examples in MongoDB Shell, Node.js, and Python, and notes about index support in planner version 2.0
Security assessment
This change adds routine documentation for a MongoDB query operator ($nin) with standard usage examples. There is no mention of security vulnerabilities, patches, or security incidents. The code examples show standard connection strings with placeholders for credentials, which is typical for documentation. The note about dollar ($) in field names references existing functional limitations documentation but doesn't indicate any security issue.
Diff
diff --git a/documentdb/latest/developerguide/nin.md b/documentdb/latest/developerguide/nin.md index 8b1378917..68af1cd05 100644 --- a//documentdb/latest/developerguide/nin.md +++ b//documentdb/latest/developerguide/nin.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#nin "Open PDF") @@ -1,0 +3,129 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $nin + +The `$nin` operator is used to match values that are not in the specified array. It is the inverse of the `$in` operator, which matches values that are in the specified array. + +Planner version 2.0 added index support for `$nin`. + +**Parameters** + + * `field`: The field to check. + + * `array`: The array of values to check against. + + + + +**Dollar (`$`) in field names** + +See [Dollar($) and dot(.) in field names](./functional-differences.html#functional-differences-dollardot) for limitations regarding querying `$` prefixed fields in `$nin` in nested objects. + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$nin` operator to find documents where the `category` field is not equal to "Fiction" or "Mystery". + +**Create sample documents** + + + db.books.insertMany([ + { title: "The Great Gatsby", author: "F. Scott Fitzgerald", category: "Fiction" }, + { title: "To Kill a Mockingbird", author: "Harper Lee", category: "Fiction" }, + { title: "The Girl on the Train", author: "Paula Hawkins", category: "Mystery" }, + { title: "The Martian", author: "Andy Weir", category: "Science Fiction" }, + { title: "The Alchemist", author: "Paulo Coelho", category: "Philosophy" } + ]) + +**Query example** + + + db.books.find({ + category: { + $nin: ["Fiction", "Mystery"] + } + }) + +**Output** + + + [ + { + _id: ObjectId('...'), + title: 'The Martian', + author: 'Andy Weir', + category: 'Science Fiction' + }, + { + _id: ObjectId('...'), + title: 'The Alchemist', + author: 'Paulo Coelho', + category: 'Philosophy' + } + ] + +## Code examples + +To view a code example for using the `$nin` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findBooksNotInCategories(categories) { + 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 books = await db.collection('books').find({ + category: { + $nin: categories + } + }).toArray(); + console.log(books); + client.close(); + } + + findBooksNotInCategories(['Fiction', 'Mystery']); + +Python + + + + from pymongo import MongoClient + + def find_books_not_in_categories(categories): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client['test'] + books = list(db.books.find({ + 'category': { + '$nin': categories + } + })) + print(books) + client.close() + + find_books_not_in_categories(['Fiction', 'Mystery']) + + **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) + +$ne + +$nor + +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.