all InfoSec news
[20 Days of DynamoDB] Day 12 - Using the DynamoDB expression package to build Projection expressions
Jan. 24, 2024, 11:21 a.m. | Abhishek Gupta
DEV Community dev.to
Posted: 23/Jan/2024
The expression package in the AWS Go SDK for DynamoDB provides a fluent builder API with types and functions to create expression strings programmatically along with corresponding expression attribute names and values.
Here is an example of how you would build a Projection Expression and use it with the GetItem API:
projectionBuilder := expression.NamesList(expression.Name("first_name"), expression.Name("last_name"))
projectionExpression, _ := expression.NewBuilder().WithProjection(projectionBuilder).Build()
_, err := client.GetItem(context.Background(), &dynamodb.GetItemInput{
TableName: aws.String("customer"),
Key: map[string]types.AttributeValue{
"email": &types.AttributeValueMemberS{Value: "c1@foo.com"},
},
ProjectionExpression: projectionExpression.Projection(),
ExpressionAttributeNames: projectionExpression.Names(),
})
Recommended …
api aws build builder cloud database dynamodb expressions functions names package sdk serverless strings types
More from dev.to / DEV Community
Jobs in InfoSec / Cybersecurity
CyberSOC Technical Lead
@ Integrity360 | Sandyford, Dublin, Ireland
Cyber Security Strategy Consultant
@ Capco | New York City
Cyber Security Senior Consultant
@ Capco | Chicago, IL
Sr. Product Manager
@ MixMode | Remote, US
Corporate Intern - Information Security (Year Round)
@ Associated Bank | US WI Remote
Senior Offensive Security Engineer
@ CoStar Group | US-DC Washington, DC