The DynamoDB client instance to use.
The scan input.
Paginate through a scan and pass each page of results to a callback.
Pagination can be aborted by returning false
(or a Promise that
resolves to false
) from the callback.
For large results this can use significantly less memory than scanAll.
An example where scan is used to delete every object in a table. (For large tables it's more efficient to delete and recreate the table.)
const scanInput = dynemeh.requestBuilder.buildScanInput(tableSchema);
await dynameh.scanHelper.scanByCallback(dynamodbClient, scanInput, async items => {
const keysToDelete = objectSchema.sortKeyField ?
items.map(item => [item[tableSchema.partitionKeyField], item[tableSchema.sortKeyField]]) :
items.map(item => item[tableSchema.partitionKeyField]);
const batchDeleteInput = dynameh.requestBuilder.buildBatchDeleteInput(tableSchema, keysToDelete);
await dynameh.batchHelper.batchWriteAll(dynamodbClient, batchDeleteInput);
return true;
});
The DynamoDB client instance to use.
The scan input.
A function that each page of results is passed to. Return
false
(or a Promise that resolves to false
) to abort the scan.
Paginate through a scan to count all results. This is more efficient than scanAll when only the count is needed.
The DynamoDB client instance to use.
The scan input.
Generated using TypeDoc
Paginate through a scan to collect all results.
For large results this can use significantly more memory than scanByCallback.