Created
July 22, 2019 09:41
-
-
Save koingdev/8edeb5dfcd77a43cb3d31a0e8c3cc61d to your computer and use it in GitHub Desktop.
AppSync Resolver PutItem with Condition Prevent Data Overwrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perfect. That's exactly what I've been looking for! Thanks a lot