AWS documentdb documentation change
Summary
Removed entire documentation page for the $first aggregation operator in Amazon DocumentDB, including all examples and code samples
Security assessment
This change removes documentation content entirely without any indication of security vulnerabilities, patches, or security-related updates. The removed content appears to be standard operator documentation with example code that includes standard connection strings with placeholder credentials. There is no evidence of addressing a specific security vulnerability or weakness in the removed content.
Diff
diff --git a/documentdb/latest/developerguide/first.md b/documentdb/latest/developerguide/first.md index 66fec8d31..8b1378917 100644 --- a//documentdb/latest/developerguide/first.md +++ b//documentdb/latest/developerguide/first.md @@ -1 +0,0 @@ -[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#first "Open PDF") @@ -3,136 +1,0 @@ -[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) - -Example (MongoDB Shell)Code examples - -# $first - -New from version 5.0. - -Not supported by Elastic cluster. - -The `$first` operator in Amazon DocumentDB returns the first document from a grouped set of documents. It is commonly used in aggregation pipelines to retrieve the first document that matches a specific condition. - -**Parameters** - - * `expression`: The expression to return as the first value in each group. - - - - -## Example (MongoDB Shell) - -The following example demonstrates the use of the `$first` operator to retrieve the first item value encountered for each category during the aggregation. - -Note: `$first` returns the first document based on the current order of documents in the pipeline. To ensure a specific order (e.g., by date, price, etc.), a `$sort` stage should be used before the `$group` stage. - -**Create sample documents** - - - db.products.insertMany([ - { _id: 1, item: "abc", price: 10, category: "food" }, - { _id: 2, item: "jkl", price: 20, category: "food" }, - { _id: 3, item: "xyz", price: 5, category: "toy" }, - { _id: 4, item: "abc", price: 5, category: "toy" } - ]); - -**Query example** - - - db.products.aggregate([ - { $group: { _id: "$category", firstItem: { $first: "$item" } } } - ]); - -**Output** - - - [ - { "_id" : "food", "firstItem" : "abc" }, - { "_id" : "toy", "firstItem" : "xyz" } - ] - -## Code examples - -To view a code example for using the `$first` command, choose the tab for the language that you want to use: - -Node.js - - - - const { MongoClient } = require('mongodb'); - - async function example() { - const uri = 'mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'; - const client = new MongoClient(uri); - - try { - await client.connect(); - - const db = client.db('test'); - const collection = db.collection('products'); - - const result = await collection.aggregate([ - { $group: { _id: "$category", firstItem: { $first: "$item" } } } - ]).toArray(); - - console.log(result); - - } catch (error) { - console.error('Error:', error); - } finally { - await client.close(); - } - } - - example(); - -Python - - - - from pymongo import MongoClient - from pprint import pprint - - def example(): - client = None - try: - 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['products'] - - result = list(collection.aggregate([ - { '$group': { '_id': '$category', 'firstItem': { '$first': '$item' } } } - ])) - - pprint(result) - - except Exception as e: - print(f"An error occurred: {e}") - - finally: - if client: - client.close() - - example() - - **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) - -$filter - -$floor - -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.