This is probably a JS / Async question rather than a specific DynamoDB question -
I want to get all the items in a table with a hash key in Amazon DynamoDB. The table also has a Range key.
I use the NodeJS library, which is a wrapper around the AWS DynamoDB REST API. - Node -DynamoDB
DynamoDB returns only 1 MB of results with each query. To get a reminder of the results, it includes lastEvaluatedKey . We can include this in another query to get another 1 MB of results and so on ...
It's hard for me to write a recursive async function that should hit the service sequentially until I can return all the results. (the table will never have more than 10 MB for my use case, no chance of a cursory request)
Some pseudo codes to illustrate:
ddb.query('products', primarykey, {}, function(err,result){ //check err if(result && result.lastEvaluatedKey){ //run the query again var tempSet = result.items; //temporarily store result.items so we can continue and fetch remaining items. } else{ var finalSet = result.items; //figure out how to merge with items that were fetched before. } });
Koder source share