Feb. 12, 2024, 2:34 a.m. | Abhishek Gupta

DEV Community dev.to

Posted: 12/Feb/2024


You can use batched operations with PartiQL as well, thanks to BatchExecuteStatement. It allows you to batch reads as well as write requests.


Here is an example (note that you cannot mix both reads and writes in a single batch):



    //read statements
client.BatchExecuteStatement(context.Background(), &dynamodb.BatchExecuteStatementInput{
Statements: []types.BatchStatementRequest{
{
Statement: aws.String("SELECT * FROM url_metadata where shortcode=?"),
Parameters: []types.AttributeValue{
&types.AttributeValueMemberS{Value: "abcd1234"},
},
},
{
Statement: aws.String("SELECT * FROM url_metadata where shortcode=?"),
Parameters: []types.AttributeValue{
&types.AttributeValueMemberS{Value: "qwer4321"},
},
},
},
})

//separate batch …

amp batch can client cloud context database dynamodb operations requests serverless single statement thanks types

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