Skip to content

Instantly share code, notes, and snippets.

@haigopi
Created October 14, 2019 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haigopi/91a500ff0bdc5116af7acee641b6ad27 to your computer and use it in GitHub Desktop.
Save haigopi/91a500ff0bdc5116af7acee641b6ad27 to your computer and use it in GitHub Desktop.
var dynamodb = new AWS.DynamoDB({
region: 'us-east-1',
endpoint: "http://localhost:15002"
});
var tableName = "default-events";
var params = {
TableName: tableName,
Select: "ALL_ATTRIBUTES"
};
function doScan(response) {
if (response.error) ppJson(response.error); // an error occurred
else {
ppJson(response.data); // successful response
// More data. Keep calling scan.
if ('LastEvaluatedKey' in response.data) {
response.request.params.ExclusiveStartKey = response.data.LastEvaluatedKey;
dynamodb.scan(response.request.params)
.on('complete', doScan)
.send();
}
}
}
console.log("Starting a Scan of the table");
dynamodb.scan(params)
.on('complete', doScan)
.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment