Created
July 22, 2019 09:33
-
-
Save koingdev/69d0f27d0c98bc3f897a0f777dcd6d44 to your computer and use it in GitHub Desktop.
Sample AppSync Resolver for PutItem Operation including with Conflict Resolution
This file contains hidden or 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), | |
"id": $util.dynamodb.toDynamoDBJson($ctx.args.id) | |
}, | |
"attributeValues" : { | |
"staffName" : $util.dynamodb.toDynamoDBJson($ctx.args.staffName), | |
"modifiedDate": $util.dynamodb.toDynamoDBJson($ctx.args.modifiedDate), | |
"createdDate": $util.dynamodb.toDynamoDBJson($ctx.args.createdDate) | |
}, | |
## Conflict Resolution with modified date | |
"condition" : { | |
## If old modifiedDate smaller than new modifiedDate ==> okay | |
## Else ==> error (Not Latest version) | |
"expression" : "modifiedDate < :modifiedDate", | |
"expressionValues" : { | |
":modifiedDate" : $util.dynamodb.toDynamoDBJson($ctx.args.modifiedDate) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment