1
votes

I am using node.js.

If you look at this example:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html

It says:

aws dynamodb scan \
    --table-name Movies \
    --projection-expression "title" \
    --filter-expression 'contains(info.genres,:gen)' \
    --expression-attribute-values '{":gen":{"S":"Sci-Fi"}}' \
    --page-size 100  \
    --debug

Where page-size limits the number of result items:

Ordinarily, the AWS CLI handles pagination automatically; however, in this example, the CLI's --page-size parameter limits the number of items per page.

But if you read the Node.js AWS documentation:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#scan-property

There is no parameters associated with "page-size".

(Only Limit which limits the number of items being scanned, not returned).

How do I limit the number of returned items (that satisfies my condition)?

1

1 Answers

0
votes

Looks like you miread the documentation,

Limiting the Number of Items in the Result Set

The Scan operation allows you to limit the number of items that it returns in the result. To do this, set the Limit parameter to the maximum number of items that you want.

For example, suppose you Scan a table, with a Limit value of 6, and without a filter expression. The Scan result will contain the first six items from the table that match the key condition expression from the request.

Now suppose you add a filter expression to the Scan. In this case, DynamoDB will apply the filter expression to the six items that were returned, discarding those that do not match. The final Scan result will contain 6 items or fewer, depending on the number of items that were filtered.

On the same link,

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html

Hope it helps.