AWS documentdb documentation change
Summary
Entire documentation page for the $arrayElemAt operator was removed, including all content, examples, and code samples
Security assessment
This change removes documentation content entirely but shows no evidence of addressing a security vulnerability. The removal appears to be a documentation restructuring or deprecation of content rather than a security fix. No security warnings, vulnerabilities, or security-related content was present in the removed material.
Diff
diff --git a/documentdb/latest/developerguide/arrayElemAt.md b/documentdb/latest/developerguide/arrayElemAt.md index 697624b7c..8b1378917 100644 --- a//documentdb/latest/developerguide/arrayElemAt.md +++ b//documentdb/latest/developerguide/arrayElemAt.md @@ -1 +0,0 @@ -[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#arrayElemAt "Open PDF") @@ -3,124 +1,0 @@ -[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) - -Example (MongoDB Shell)Code examples - -# $arrayElemAt - -The `$arrayElemAt` operator in Amazon DocumentDB allows you to retrieve an element from an array by its index position. This is particularly useful when you need to access a specific element within an array field in your documents. - -**Parameters** - - * `array`: The input array from which an element is to be retrieved. - - * `index`: The zero-based index position of the element to retrieve. This value must be a non-negative integer. - - - - -## Example (MongoDB Shell) - -In this example, we'll demonstrate how to use the `$arrayElemAt` operator to retrieve specific elements from the `flight_miles` array in the `miles` collection. - -**Create sample documents** - - - db.miles.insertMany([ - { "_id" : 1, "member_since" : ISODate("1987-01-01T00:00:00Z"), "credit_card" : false, "flight_miles" : [ 1205, 2560, 880 ]}, - { "_id" : 2, "member_since" : ISODate("1982-01-01T00:00:00Z"), "credit_card" : true, "flight_miles" : [ 1205, 2560, 890, 2780 ]}, - { "_id" : 3, "member_since" : ISODate("1999-01-01T00:00:00Z"), "credit_card" : true, "flight_miles" : [ 1205, 880 ]} - ]); - -**Query example** - - - db.miles.aggregate([ - { $project: { - "_id": 1, - "first_mile": { $arrayElemAt: [ "$flight_miles", 0 ] }, - "last_mile": { $arrayElemAt: [ "$flight_miles", -1 ] } - }} - ]); - -**Output** - - - { "_id" : 1, "first_mile" : 1205, "last_mile" : 880 } - { "_id" : 2, "first_mile" : 1205, "last_mile" : 2780 } - { "_id" : 3, "first_mile" : 1205, "last_mile" : 880 } - -In this example, we use the `$arrayElemAt` operator to retrieve the first and last elements of the `flight_miles` array for each document. - -## Code examples - -To view a code example for using the `$arrayElemAt` command, choose the tab for the language that you want to use: - -Node.js - - - - const { MongoClient } = require('mongodb'); - - async function example() { - 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('miles'); - - const result = await collection.aggregate([ - { $project: { - "_id": 1, - "first_mile": { $arrayElemAt: [ "$flight_miles", 0 ] }, - "last_mile": { $arrayElemAt: [ "$flight_miles", -1 ] } - }} - ]).toArray(); - - console.log(result); - client.close(); - } - - example(); - -Python - - - - from pymongo import MongoClient - - def example(): - client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') - db = client.mydatabase - collection = db.miles - - result = list(collection.aggregate([ - { "$project": { - "_id": 1, - "first_mile": { "$arrayElemAt": [ "$flight_miles", 0 ] }, - "last_mile": { "$arrayElemAt": [ "$flight_miles", -1 ] } - }} - ])) - - print(result) - 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) - -$anyElementTrue - -$arrayToObject - -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.