Skip to content

Commit

Permalink
FIX: batchWrite unprocessedItems
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Dec 8, 2021
1 parent 7164a40 commit c00fead
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export class Table {
} else if (err.code == 'ConditionalCheckFailedException' && op == 'put') {
// Not a hard error -- typically part of normal operation
this.log.info(`Conditional check failed "${op}" on "${model}"`, {err, trace})
throw new OneError(`Conditional create failed for "${model}`, {code: 'Condition', trace, err})
throw new OneError(`Conditional create failed for "${model}"`, {code: 'Condition', trace, err})

} else {
result = result || {}
Expand Down Expand Up @@ -595,7 +595,16 @@ export class Table {
if (Object.getOwnPropertyNames(batch).length == 0) {
return {}
}
return await this.execute(GenericModel, 'batchWrite', batch, params)
let more
do {
more = false
let response = await this.execute(GenericModel, 'batchWrite', batch, params)
let data = response.data
if (data && data.UnprocessedItems && Object.keys(data.UnprocessedItems).length) {
batch.RequestItems = data.UnprocessedItems
more = true
}
} while (more)
}

async deleteItem(properties, params) {
Expand Down

0 comments on commit c00fead

Please sign in to comment.