0
0
DynamoDBquery~10 mins

Pagination with SDK in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to fetch the first page of items from a DynamoDB table using the SDK.

DynamoDB
const params = { TableName: 'Users', Limit: [1] };
const data = await dynamoDbClient.scan(params).promise();
Drag options to blanks, or click blank then click option'
Anull
B100
C0
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Setting Limit to 0 returns no items.
Using null for Limit causes an error.
2fill in blank
medium

Complete the code to continue fetching the next page using the LastEvaluatedKey.

DynamoDB
const params = { TableName: 'Users', Limit: 10, ExclusiveStartKey: [1] };
const data = await dynamoDbClient.scan(params).promise();
Drag options to blanks, or click blank then click option'
Anull
Bdata.LastEvaluatedKey
Cundefined
D{}
Attempts:
3 left
💡 Hint
Common Mistakes
Passing null or undefined causes DynamoDB to start from the beginning.
Using an empty object {} does not work as a start key.
3fill in blank
hard

Fix the error in the code to correctly check if there are more pages to fetch.

DynamoDB
if (data.[1]) {
  // fetch next page
}
Drag options to blanks, or click blank then click option'
AMoreResults
BNextPageKey
CLastEvaluatedKey
DHasNext
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like NextPageKey or HasNext.
Checking for a boolean instead of the key object.
4fill in blank
hard

Fill both blanks to correctly set up the scan parameters for paginated fetching.

DynamoDB
const params = { TableName: 'Orders', Limit: [1], ExclusiveStartKey: [2] };
const data = await dynamoDbClient.scan(params).promise();
Drag options to blanks, or click blank then click option'
A20
Bdata.LastEvaluatedKey
Cnull
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using data.LastEvaluatedKey on the first page causes errors.
Setting Limit too high or zero.
5fill in blank
hard

Fill all three blanks to build a loop that fetches all pages from a DynamoDB table.

DynamoDB
let lastKey = [1];
do {
  const params = { TableName: 'Products', Limit: [2], ExclusiveStartKey: lastKey };
  const data = await dynamoDbClient.scan(params).promise();
  // process data.Items
  lastKey = data.[3];
} while (lastKey);
Drag options to blanks, or click blank then click option'
Anull
B50
CLastEvaluatedKey
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Starting lastKey as undefined causes errors.
Not updating lastKey inside the loop.
Using wrong property name for the next key.