DEV Community

Abhishek Gupta for AWS

Posted on • Originally published at

[20 Days of DynamoDB] Day 2 - GetItem add-on benefits

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,
Enter fullscreen mode Exit fullscreen mode

Recommended reading:

Top comments (0)