This repository was archived by the owner on Dec 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -20,20 +20,7 @@ export default class Provisioner extends ProvisionerConfigurableBase {
20
20
async getTableNamesAsync ( ) : Promise < string [ ] > {
21
21
22
22
// Option 1 - All tables (Default)
23
- // The output from ListTables is paginated, with each page
24
- // returning a maximum of 100 table names.
25
- let listTablesResponse = await this . db . listTablesAsync ( ) ;
26
- var tableNames = listTablesResponse . TableNames ;
27
- var lastTable = listTablesResponse . LastEvaluatedTableName ;
28
-
29
- while ( lastTable ) {
30
- var params = { ExclusiveStartTableName : lastTable } ;
31
- let listTablesResponse = await this . db . listTablesAsync ( params ) ;
32
- tableNames = tableNames . concat ( listTablesResponse . TableNames ) ;
33
- lastTable = listTablesResponse . LastEvaluatedTableName ;
34
- }
35
-
36
- return tableNames ;
23
+ return await this . db . listAllTableNamesAsync ( ) ;
37
24
38
25
// Option 2 - Hardcoded list of tables
39
26
// return ['Table1', 'Table2', 'Table3'];
Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ export default class DynamoDB {
46
46
}
47
47
}
48
48
49
+ async listAllTableNamesAsync ( ) : Promise < string [ ] > {
50
+ let tableNames = [ ] ;
51
+ let lastTable ;
52
+ do {
53
+ let listTablesResponse = await this . listTablesAsync ( { ExclusiveStartTableName : lastTable } ) ;
54
+ tableNames = tableNames . concat ( listTablesResponse . TableNames ) ;
55
+ lastTable = listTablesResponse . LastEvaluatedTableName ;
56
+ } while ( lastTable ) ;
57
+ return tableNames ;
58
+ }
59
+
49
60
async describeTableAsync ( params : DescribeTableRequest ) : Promise < DescribeTableResponse > {
50
61
let sw = stats . timer ( 'DynamoDB.describeTableAsync' ) . start ( ) ;
51
62
try {
You can’t perform that action at this time.
0 commit comments