Alex Montoya
Alex Montoya

Reputation: 5089

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

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.

Upvotes: 8

Views: 6545

Answers (2)

Alex Montoya
Alex Montoya

Reputation: 5089

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"),
}

Upvotes: 14

GoPro
GoPro

Reputation: 728

AWS SDK Go V2 Developer guide is a good place to start.

Recommend taking a look at https://aws.github.io/aws-sdk-go-v2/docs/getting-started/

Upvotes: -8

Related Questions