How to get item by key in dynamodb using AWS SDK v2?

Viewed 2449

I am learning Golang to connect dynamodb using AWS-SDK-GO-V2 but I do not understand how to get one item by key.

All example that i saw it is using the v1 but I NEED WITH V2.

2 Answers

I found the solution in reddit

Example

getItemInput := &dynamodb.GetItemInput{
  Key: map[string]types.AttributeValue{
    "Id": &types.AttributeValueMemberS{Value: id},
  },
  TableName:            aws.String("TableName"),
  ConsistentRead:       aws.Bool(true),
  ProjectionExpression: aws.String("Id, Name, Timestamp"),
}
Related