-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
documentationThis is a problem with documentation.This is a problem with documentation.
Description
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow for answers
- I've searched for previous similar issues and didn't find any solution
- This is an issue with version 2.x of the SDK
Describe the bug
I am trying pagination with LSI, my table has 3 LSI. Upon reaching the last record it should not return LastevaluatedKey, however it returns LastEvaluatedKey which makes it difficult to paginate backward.
Other 2 LSI index are working fine and keeps LastEvaluatedKey as null for last records
If on Node.js, are you running this on AWS Lambda?
yes i am running on AWS Lambda
Details of the browser/Node.js version
v16.1.0
SDK version number
v2.970.0
To Reproduce (observed behavior)
params.ScanIndexForward = false;
response = await dynamoDb.query(paramsForQuery).promise();
console.log('response', response);
const arrayLength = response.Items.length;
LastEvalSortKey = {
pk: userId,
originalUrl: response.Items[0].originalUrl,
};
if (sortBy === 'createdAt')
LastEvalSortKey[sortBy] = response.Items[0].createdAt;
if (sortBy === 'updatedAt')
LastEvalSortKey[sortBy] = response.Items[0].updatedAt;
if (sortBy === 'convertedUrl')
LastEvalSortKey[sortBy] = response.Items[0].convertedUrl;
return {
items: response.Items,
nextToken: arrayLength
? Base64.encodeURI(JSON.stringify(LastEvalSortKey))
: prevToken,
prevToken: response.LastEvaluatedKey
? Base64.encodeURI(JSON.stringify(response.LastEvaluatedKey))
: undefined,
};
Expected behavior
response.LastEvaluatedKey should be null for last record which is not, how to determine last record for reverse pagination.
Metadata
Metadata
Assignees
Labels
documentationThis is a problem with documentation.This is a problem with documentation.