Using javascript aws-sdk and querying a dynamodb table, with document client. the table contains 10 elements and the query limit = 5.
For each request I use the LastEvaluatedKey to build a new query and send a fresh request, here are the results :
first request --> {Items: Array(5), Count: 5, ScannedCount: 5, LastEvaluatedKey: {…}}
second request --> {Items: Array(5), Count: 5, ScannedCount: 5, LastEvaluatedKey: {…}}
third request --> {Items: Array(0), Count: 0, ScannedCount: 0}
According to this doc
If the result contains a LastEvaluatedKey element, proceed to step 2. If there is not a LastEvaluatedKey in the result, then there are no more items to be retrieved
It is supposed to not return LastEvaluatedKey in the second request, cause there is no more elements, but it returns one which send to an empty result in the third request.
When i try with limit = 4, every things works as expected
first request --> {Items: Array(4), Count: 4, ScannedCount: 4, LastEvaluatedKey: {…}}
second request --> {Items: Array(4), Count: 4, ScannedCount: 4, LastEvaluatedKey: {…}}
third request --> {Items: Array(2), Count: 2, ScannedCount: 2} <--- there is no LastEvaluatedKey as expected
So what is happening here ?