DEV Community

Abhishek Gupta for AWS

Posted on • Originally published at community.aws

3 1 1 1 1

[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:

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay