AWS documentdb documentation change
Summary
Entire documentation page for the $switch operator in Amazon DocumentDB has been removed, including all content, examples, and code samples
Security assessment
The change removes documentation content entirely without any mention of security vulnerabilities, patches, or security-related issues. This appears to be a documentation restructuring or removal of a feature page, but there is no evidence in the diff that this is related to addressing a security vulnerability or weakness.
Diff
diff --git a/documentdb/latest/developerguide/switch.md b/documentdb/latest/developerguide/switch.md index 44423c766..8b1378917 100644 --- a//documentdb/latest/developerguide/switch.md +++ b//documentdb/latest/developerguide/switch.md @@ -1 +0,0 @@ -[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#switch "Open PDF") @@ -3,174 +1,0 @@ -[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) - -Example (MongoDB Shell)Code examples - -# $switch - -New from version 4.0. - -Not supported by Elastic cluster. - -The `$switch` operator is a conditional expression operator in Amazon DocumentDB that allows you to evaluate a list of case expressions and return the value of the first case that evaluates to true, or a default value if no case expression is true. - -**Parameters** - - * `branches`: An array of documents, each of which has a case field that contains the boolean expression to evaluate, and a then field that contains the value to return if the case expression is true. - - * `default`: (optional) The value to return if none of the case expressions are true. - - - - -## Example (MongoDB Shell) - -The following example demonstrates the use of the `$switch` operator to determine the shipping cost for an order based on the order total. - -**Create sample documents** - - - db.orders.insertMany([ - { _id: 1, total: 50 }, - { _id: 2, total: 150 }, - { _id: 3, total: 250 } - ]); - -**Query example** - - - db.orders.aggregate([ - { - $project: { - _id: 1, - total: 1, - shippingCost: { - $switch: { - branches: [ - { case: { $lte: ["$total", 100] }, then: 5 }, - { case: { $lte: ["$total", 200] }, then: 10 }, - { case: { $gt: ["$total", 200] }, then: 15 } - ], - default: 0 - } - } - } - } - ]) - -**Output** - - - [ - { - "_id": 1, - "total": 50, - "shippingCost": 5 - }, - { - "_id": 2, - "total": 150, - "shippingCost": 10 - }, - { - "_id": 3, - "total": 250, - "shippingCost": 15 - } - ] - -## Code examples - -To view a code example for using the `$switch` 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('orders'); - - const result = await collection.aggregate([ - { - $project: { - _id: 1, - total: 1, - shippingCost: { - $switch: { - branches: [ - { case: { $lte: ['$total', 100] }, then: 5 }, - { case: { $lte: ['$total', 200] }, then: 10 }, - { case: { $gt: ['$total', 200] }, then: 15 } - ], - default: 0 - } - } - } - } - ]).toArray(); - - console.log(result); - await client.close(); - } - - main(); - -Python - - - - from pymongo import MongoClient - - def main(): - 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.orders - - result = list(collection.aggregate([ - { - '$project': { - '_id': 1, - 'total': 1, - 'shippingCost': { - '$switch': { - 'branches': [ - { 'case': { '$lte': ['$total', 100] }, 'then': 5 }, - { 'case': { '$lte': ['$total', 200] }, 'then': 10 }, - { 'case': { '$gt': ['$total', 200] }, 'then': 15 } - ], - 'default': 0 - } - } - } - } - ])) - - print(result) - client.close() - - if __name__ == '__main__': - main() - - **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) - -$sum - -$toBool - -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.