Skip to content

Instantly share code, notes, and snippets.

@koingdev
Created July 22, 2019 09:41
Show Gist options
  • Save koingdev/8edeb5dfcd77a43cb3d31a0e8c3cc61d to your computer and use it in GitHub Desktop.
Save koingdev/8edeb5dfcd77a43cb3d31a0e8c3cc61d to your computer and use it in GitHub Desktop.
AppSync Resolver PutItem with Condition Prevent Data Overwrite
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
"shopID": $util.dynamodb.toDynamoDBJson($ctx.args.shopID),
"vendorID": $util.dynamodb.toDynamoDBJson($ctx.args.vendorID)
},
"attributeValues": {
"name": $util.dynamodb.toDynamoDBJson($ctx.args.name)
},
## ADD NEW ITEM IF SHOP ID AND VENDOR ID NOT YET EXIST
"condition": {
"expression": "attribute_not_exists(shopID) AND attribute_not_exists(vendorID)"
}
}
@MEGApixel23
Copy link

Perfect. That's exactly what I've been looking for! Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment