Skip to content

Commit

Permalink
Refactor custom type handling
Browse files Browse the repository at this point in the history
Add unique constraint on (batchID,BATCH#batchID)
  • Loading branch information
pschork committed Jul 25, 2024
1 parent 1527325 commit 41cdbfd
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 200 deletions.
12 changes: 12 additions & 0 deletions common/aws/dynamodb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ func (c *Client) PutItem(ctx context.Context, tableName string, item Item) (err
return nil
}

func (c *Client) PutItemWithCondition(ctx context.Context, tableName string, item Item, condition string) (err error) {
_, err = c.dynamoClient.PutItem(ctx, &dynamodb.PutItemInput{
TableName: aws.String(tableName), Item: item,
ConditionExpression: aws.String(condition),
})
if err != nil {
return err
}

return nil
}

// PutItems puts items in batches of 25 items (which is a limit DynamoDB imposes)
// It returns the items that failed to be put.
func (c *Client) PutItems(ctx context.Context, tableName string, items []Item) ([]Item, error) {
Expand Down
Loading

0 comments on commit 41cdbfd

Please sign in to comment.