diff --git a/client.go b/client.go index 7e31f63..924ed36 100644 --- a/client.go +++ b/client.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) type ClientOptions struct { @@ -25,6 +26,8 @@ type Client struct { Keys map[string]string } +type TransactWriteItem types.TransactWriteItem + // Create a new instance of DynamoTable. internally creates aws connection configuration for the db // If DynamoTable.Endpoint is specified connects to the db at the given URL, or the default credential of the system is used // To connect to AWS DynamoDB from a running pod or EC2 instance, use the default credentials without Endpoint option diff --git a/tests/transact_items_test.go b/tests/transact_items_test.go index 5292c5d..e1557c7 100644 --- a/tests/transact_items_test.go +++ b/tests/transact_items_test.go @@ -102,7 +102,7 @@ func TestTransactItems(t *testing.T) { } //perform operations if len(tc.operations) > 0 { - err := table.TransactItems(ctx, tc.operations) + err := table.TransactItems(ctx, tc.operations...) if err != nil { t.Fatalf("error occurred %s", err) } diff --git a/transaction_items.go b/transaction_items.go index 79ded31..4476282 100644 --- a/transaction_items.go +++ b/transaction_items.go @@ -46,7 +46,7 @@ func (t *Client) WithPutItem(pk string, sk string, item interface{}) types.Trans // TransactItems is a synchronous for writing or deletion operation performed in dynamodb grouped together -func (t *Client) TransactItems(ctx context.Context, input []types.TransactWriteItem) error { +func (t *Client) TransactItems(ctx context.Context, input ...types.TransactWriteItem) error { _, err := t.client.TransactWriteItems(ctx, &dynamodb.TransactWriteItemsInput{ TransactItems: input, })