Skip to content

Commit

Permalink
add IncludeItemInCondCheckFail to ConditionCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed Aug 26, 2024
1 parent 973bed6 commit 6db982f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions conditioncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type ConditionCheck struct {
rangeKey string
rangeValue types.AttributeValue

condition string
condition string
onCondFail types.ReturnValuesOnConditionCheckFailure
subber

err error
Expand Down Expand Up @@ -74,6 +75,15 @@ func (check *ConditionCheck) IfNotExists() *ConditionCheck {
return check.If("attribute_not_exists($)", check.hashKey)
}

func (check *ConditionCheck) IncludeItemInCondCheckFail(enabled bool) *ConditionCheck {
if enabled {
check.onCondFail = types.ReturnValuesOnConditionCheckFailureAllOld
} else {
check.onCondFail = types.ReturnValuesOnConditionCheckFailureNone
}
return check
}

func (check *ConditionCheck) writeTxItem() (*types.TransactWriteItem, error) {
if check.err != nil {
return nil, check.err
Expand All @@ -86,7 +96,7 @@ func (check *ConditionCheck) writeTxItem() (*types.TransactWriteItem, error) {
}
if check.condition != "" {
item.ConditionExpression = aws.String(check.condition)
item.ReturnValuesOnConditionCheckFailure = types.ReturnValuesOnConditionCheckFailureAllOld
item.ReturnValuesOnConditionCheckFailure = check.onCondFail
}
return &types.TransactWriteItem{
ConditionCheck: item,
Expand Down

0 comments on commit 6db982f

Please sign in to comment.