Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppSync Batch Update Item?

According to the documentation, it seems like AppSync doesn't support BatchUpdateItem (only supports BatchPutItem and BatchGetItem). I have a use case where I want to update a particular attribute of multiple items in a table. Is there an efficient way to do this in AppSync and DynamoDB? I cannot do a batchPutItem because I could be overwriting the item with expired attributes (another client updated an attribute). So the only option is to do UpdateItem one item at a time. I am thinking of having a loop in my iOS app that calls UpdateItem n times. Does this mean that there would be n network rounds? I want to be efficient with my design. Is there anyway I can do all the updates in one network round trip? Thank you.

like image 459
Sarah Guo Avatar asked Oct 15 '25 04:10

Sarah Guo


1 Answers

Is there anyway I can do all the updates in one network round trip?

I think you're on to a reasonable approach with this line of questioning.

You could try setting up a mutation to be handled by a Lambda function data source. Have the Lambda function do your looping and report back with any conflicts. That way you can do it all in one network call.

More about Lambda resolvers here: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html

like image 192
Gabe Hollombe Avatar answered Oct 17 '25 21:10

Gabe Hollombe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!