Posted: 9/Jan/2024
Did you know that the DynamoDB GetItem
operation also gives you the ability to:
- Switch to strongly consistent read (eventually consistent being the default)
- Use a projection expression to return only some of the attributes
- Return the consumed Read Capacity Units (RCU)
Here is an example (DynamoDB Go SDK):
resp,err:=client.GetItem(context.Background(),&dynamodb.GetItemInput{TableName:aws.String(tableName),Key:map[string]types.AttributeValue{//email - partition key"email":&types.AttributeValueMemberS{Value:email},},ConsistentRead:aws.Bool(true),ProjectionExpression:aws.String("first_name, last_name"),ReturnConsumedCapacity:types.ReturnConsumedCapacityTotal,})
Recommended reading: