Skip to content

Commit

Permalink
add func comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtwinkle committed Jul 25, 2023
1 parent d5f5b0b commit 1c2e23b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions aws/awsdynamo/awsdynamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
ErrNotFound = errors.New("record not found")
)

// PutItem DynamoDBのitemを置き換える 存在しない場合はUpsertする
// PutItem Put the item in DynamoDB Upsert if it does not exist
func PutItem(ctx context.Context, region awsconfig.Region, tableName string, item any, opts ...dynamooptions.OptionDynamo) error {
c := dynamooptions.GetDynamoConf(opts...)
client, err := GetClient(ctx, region, c.MaxAttempts, c.MaxBackoffDelay)
Expand All @@ -43,7 +43,7 @@ func PutItem(ctx context.Context, region awsconfig.Region, tableName string, ite
return nil
}

// UpdateItem DynamoDBのitemの属性を更新する 存在しない場合はUpsertする
// UpdateItem Update the attributes of the item in DynamoDB Upsert if it does not exist
// expression: https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/expression/#example_Builder_WithUpdate
func UpdateItem(
ctx context.Context,
Expand Down Expand Up @@ -87,9 +87,9 @@ func UpdateItem(
return nil
}

// DeleteItem DynamoDBのitemを削除する
// DeleteItem Delete DynamoDB item
// expression: https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/expression/#example_Builder_WithUpdate
// 取得したitemを `out` にMappingします `out` は必ずpointerで引き渡してください
// Mapping the retrieved item to `out`, must be a pointer to the `out`.
func DeleteItem(ctx context.Context, region awsconfig.Region, tableName, keyFieldName, key string, out any, opts ...dynamooptions.OptionDynamo) error {
c := dynamooptions.GetDynamoConf(opts...)
client, err := GetClient(ctx, region, c.MaxAttempts, c.MaxBackoffDelay)
Expand Down Expand Up @@ -118,8 +118,8 @@ func DeleteItem(ctx context.Context, region awsconfig.Region, tableName, keyFiel
return nil
}

// GetItem DynamoDBのitemを取得する
// 取得したitemを `out` にMappingします `out` は必ずpointerで引き渡してください
// GetItem Get the item in DynamoDB
// Mapping the retrieved item to `out`, must be a pointer to the `out`.
func GetItem(ctx context.Context, region awsconfig.Region, tableName, keyFieldName, key string, out any, opts ...dynamooptions.OptionDynamo) error {
c := dynamooptions.GetDynamoConf(opts...)
client, err := GetClient(ctx, region, c.MaxAttempts, c.MaxBackoffDelay)
Expand Down Expand Up @@ -147,9 +147,9 @@ func GetItem(ctx context.Context, region awsconfig.Region, tableName, keyFieldNa
return nil
}

// BatchGetItem DynamoDBのitemを取得する
// 取得したitemを `T` の型のsliceで返却します
// 取得順はkeyの指定順ではないので注意
// BatchGetItem Retrieve Dynamodb items in a batch process
// Return the retrieved item as a slice of type `T`.
// Note that the order of retrieval is not the order in which the keys are specified.
func BatchGetItem[T any, Key ~string](ctx context.Context, region awsconfig.Region, tableName, keyFieldName string, keys []Key, _ T, opts ...dynamooptions.OptionDynamo) ([]T, error) {
// DynamoDB allows a maximum batch size of 100 items.
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html
Expand Down Expand Up @@ -203,7 +203,7 @@ func BatchGetItem[T any, Key ~string](ctx context.Context, region awsconfig.Regi
return resultItems, nil
}

// BatchWriteItem
// BatchWriteItem Write Dynamodb items in a batch process
func BatchWriteItem[T any](ctx context.Context, region awsconfig.Region, tableName string, items []T, opts ...dynamooptions.OptionDynamo) error {
// DynamoDB allows a maximum batch size of 25 items.
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
Expand Down

0 comments on commit 1c2e23b

Please sign in to comment.