AWS documentdb documentation change
Summary
Removed entire documentation page for the $slice aggregation operator, including all examples, code snippets, and explanatory content
Security assessment
This change appears to be a routine documentation cleanup or restructuring, removing an entire page about the $slice operator functionality. There is no evidence in the diff of any security vulnerability being addressed, no mention of security issues, and no security-related content being added. The removed content was purely functional documentation about a MongoDB aggregation operator.
Diff
diff --git a/documentdb/latest/developerguide/slice.md b/documentdb/latest/developerguide/slice.md index 846a0d353..8b1378917 100644 --- a//documentdb/latest/developerguide/slice.md +++ b//documentdb/latest/developerguide/slice.md @@ -1 +0,0 @@ -[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#slice "Open PDF") @@ -3,116 +1,0 @@ -[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) - -Example (MongoDB Shell)Code examples - -# $slice - -The `$slice` aggregation operator enables you to return a subset of an array by either traversing the array from the beginning or the end of the array. This is used to display a limited number of items from an array field, such as the top or bottom N items. - -**Parameters** - - * `array`: The array field to be sliced. - - * `n`: An integer that specifies the number of elements to return. A positive value starts from the beginning of the array, while a negative value starts from the end of the array. - - - - -## Example (MongoDB Shell) - -The following example demonstrates how to use `$slice` to return the first two favorite sweets for each chef. - -**Create sample documents** - - - db.sweets.insertMany([ - { "_id" : 1, "name" : "Alvin", "favorites": [ "chocolate", "cake", "toffee", "beignets" ] }, - { "_id" : 2, "name" : "Tom", "favorites": [ "donuts", "pudding", "pie" ] }, - { "_id" : 3, "name" : "Jessica", "favorites": [ "fudge", "smores", "pudding", "cupcakes" ] }, - { "_id" : 4, "name" : "Rachel", "favorites": [ "ice cream" ] } - ]); - -**Query example** - - - db.sweets.aggregate([ - { $project: { _id: 0, name: 1, topTwoFavorites: { $slice: [ "$favorites", 2 ] } } } - ]); - -**Output** - - - [ - { name: 'Alvin', topTwoFavorites: [ 'chocolate', 'cake' ] }, - { name: 'Tom', topTwoFavorites: [ 'donuts', 'pudding' ] }, - { name: 'Jessica', topTwoFavorites: [ 'fudge', 'smores' ] }, - { name: 'Rachel', topTwoFavorites: [ 'ice cream' ] } - ] - -In this example, the `$slice` operator is used to extract the first two elements from the `favorites` array for each document. - -## Code examples - -To view a code example for using the `$slice` 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('sweets'); - - const result = await collection.aggregate([ - { $project: { name: 1, topTwoFavorites: { $slice: ['$favorites', 2] } } } - ]).toArray(); - - console.log(result); - await 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['test'] - collection = db['sweets'] - - result = list(collection.aggregate([ - { '$project': { 'name': 1, 'topTwoFavorites': { '$slice': ['$favorites', 2] } } } - ])) - - 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) - -$skip - -$size - -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.