idea-aws 3.7.2 → 3.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/dynamoDB.js
CHANGED
|
@@ -157,12 +157,14 @@ class DynamoDB {
|
|
|
157
157
|
(0, idea_toolbox_1.logger)(`BATCH GET ${table}`, null, 'No elements to get');
|
|
158
158
|
return [];
|
|
159
159
|
}
|
|
160
|
-
await this.batchGetHelper(table, keys, [], Boolean(ignoreErr));
|
|
160
|
+
return await this.batchGetHelper(table, keys, [], Boolean(ignoreErr));
|
|
161
161
|
}
|
|
162
162
|
async batchGetHelper(table, keys, resultElements, ignoreErr, currentChunk = 0, chunkSize = 100) {
|
|
163
|
-
const batch = {
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const batch = {
|
|
164
|
+
RequestItems: {
|
|
165
|
+
[table]: { Keys: keys.slice(currentChunk, currentChunk + chunkSize) }
|
|
166
|
+
}
|
|
167
|
+
};
|
|
166
168
|
(0, idea_toolbox_1.logger)(`BATCH GET ${table}`, null, `${currentChunk} of ${keys.length}`);
|
|
167
169
|
let result;
|
|
168
170
|
try {
|
|
@@ -176,9 +178,10 @@ class DynamoDB {
|
|
|
176
178
|
resultElements = resultElements.concat(result.Responses[table]);
|
|
177
179
|
// if there are still chunks to manage, go on recursively
|
|
178
180
|
if (currentChunk + chunkSize < keys.length)
|
|
179
|
-
await this.batchGetHelper(table, keys, resultElements, ignoreErr, currentChunk + chunkSize, chunkSize);
|
|
181
|
+
return await this.batchGetHelper(table, keys, resultElements, ignoreErr, currentChunk + chunkSize, chunkSize);
|
|
180
182
|
// no more chunks to manage: we're done
|
|
181
|
-
|
|
183
|
+
else
|
|
184
|
+
return resultElements;
|
|
182
185
|
}
|
|
183
186
|
/**
|
|
184
187
|
* Put an array of items in a DynamoDb table, avoiding the limits of DynamoDB's BatchWriteItem.
|
|
@@ -263,7 +266,7 @@ class DynamoDB {
|
|
|
263
266
|
items = items.concat(result.Items);
|
|
264
267
|
if (result.LastEvaluatedKey) {
|
|
265
268
|
params.ExclusiveStartKey = result.LastEvaluatedKey;
|
|
266
|
-
await this.queryScanHelper(params, items, isQuery);
|
|
269
|
+
return await this.queryScanHelper(params, items, isQuery);
|
|
267
270
|
}
|
|
268
271
|
else
|
|
269
272
|
return items;
|
|
@@ -19,8 +19,7 @@ class GenericController {
|
|
|
19
19
|
* @param event the event that invoked the AWS lambda function
|
|
20
20
|
* @param callback the callback to resolve or reject the execution
|
|
21
21
|
*/
|
|
22
|
-
constructor(event, callback, options) {
|
|
23
|
-
options = options || {};
|
|
22
|
+
constructor(event, callback, options = {}) {
|
|
24
23
|
this.event = event;
|
|
25
24
|
this.callback = callback;
|
|
26
25
|
this.tables = options.tables || {};
|
|
@@ -10,7 +10,7 @@ const genericController_1 = require("./genericController");
|
|
|
10
10
|
* An abstract class to inherit to manage API requests (AWS API Gateway) in an AWS Lambda function.
|
|
11
11
|
*/
|
|
12
12
|
class ResourceController extends genericController_1.GenericController {
|
|
13
|
-
constructor(event, callback, options) {
|
|
13
|
+
constructor(event, callback, options = {}) {
|
|
14
14
|
super(event, callback, options);
|
|
15
15
|
this.templateMatcher = /{{\s?([^{}\s]*)\s?}}/g;
|
|
16
16
|
///
|
|
@@ -7,7 +7,7 @@ const genericController_1 = require("./genericController");
|
|
|
7
7
|
* An abstract class to inherit to manage AWS DDB streams in an AWS Lambda function.
|
|
8
8
|
*/
|
|
9
9
|
class StreamController extends genericController_1.GenericController {
|
|
10
|
-
constructor(event, callback, options) {
|
|
10
|
+
constructor(event, callback, options = {}) {
|
|
11
11
|
super(event, callback, options);
|
|
12
12
|
this.records = event.Records || [];
|
|
13
13
|
(0, idea_toolbox_1.logger)(`START STREAM: ${this.records.length || 0} records`, null, null, true);
|