@moicky/dynamodb 2.2.0 → 2.2.1
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.
|
@@ -101,7 +101,7 @@ async function deleteItems(keys, args = {}, retry = 0) {
|
|
|
101
101
|
if (res?.UnprocessedItems?.[table]?.length) {
|
|
102
102
|
if (retry + 1 > 3)
|
|
103
103
|
return reject(res);
|
|
104
|
-
return deleteItems(res.UnprocessedItems[table], args, retry + 1);
|
|
104
|
+
return deleteItems(res.UnprocessedItems[table].map((d) => d?.DeleteRequest?.Key), { ...args, TableName: table }, retry + 1);
|
|
105
105
|
}
|
|
106
106
|
})
|
|
107
107
|
.catch(reject);
|
package/dist/operations/put.d.ts
CHANGED
|
@@ -42,5 +42,5 @@ type PutItemsArgs = Partial<BatchWriteItemCommandInput & {
|
|
|
42
42
|
* ]);
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
export declare function putItems(items: any[], args?: PutItemsArgs): Promise<BatchWriteItemCommandOutput[]>;
|
|
45
|
+
export declare function putItems(items: any[], args?: PutItemsArgs, retry?: number): Promise<BatchWriteItemCommandOutput[]>;
|
|
46
46
|
export {};
|
package/dist/operations/put.js
CHANGED
|
@@ -56,7 +56,9 @@ exports.putItem = putItem;
|
|
|
56
56
|
* ]);
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
async function putItems(items, args = {}) {
|
|
59
|
+
async function putItems(items, args = {}, retry = 0) {
|
|
60
|
+
if (retry > 3)
|
|
61
|
+
return;
|
|
60
62
|
args = (0, lib_1.withDefaults)(args, "putItems");
|
|
61
63
|
return new Promise(async (resolve, reject) => {
|
|
62
64
|
const now = Date.now();
|
|
@@ -78,7 +80,16 @@ async function putItems(items, args = {}) {
|
|
|
78
80
|
},
|
|
79
81
|
...args,
|
|
80
82
|
}))
|
|
81
|
-
.then((res) =>
|
|
83
|
+
.then((res) => {
|
|
84
|
+
results.push(res);
|
|
85
|
+
if (res?.UnprocessedItems?.[table]?.length) {
|
|
86
|
+
if (retry + 1 < 3) {
|
|
87
|
+
reject(res);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
return putItems(res.UnprocessedItems[table].map((item) => (0, lib_1.unmarshallWithOptions)(item.PutRequest.Item)), { ...args, TableName: table }, retry + 1);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
82
93
|
.catch(reject);
|
|
83
94
|
}
|
|
84
95
|
resolve(results);
|