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

SOC 2 Manager, Audit and Certification

@ Deloitte | US and CA Multiple Locations

Professional Services Resident Consultant / Senior Professional Services Resident Consultant - AMS

@ Zscaler | Bengaluru, India

Head of Security, Risk & Compliance

@ Gedeon Richter Pharma GmbH | Budapest, HU

Unarmed Professional Security Officer - County Hospital

@ Allied Universal | Los Angeles, CA, United States

Senior Software Engineer, Privacy Engineering

@ Block | Seattle, WA, United States

Senior Cyber Security Specialist

@ Avaloq | Bioggio, Switzerland