Skip to content

Instantly share code, notes, and snippets.

@howyi
Created December 2, 2019 17:02
Show Gist options
  • Save howyi/17fbee9f778682c50820e9b4019d4741 to your computer and use it in GitHub Desktop.
Save howyi/17fbee9f778682c50820e9b4019d4741 to your computer and use it in GitHub Desktop.
## [Start] Inject @versioned condition.. **
#set( $versionedCondition = {
"expression": "#version = :expectedVersion",
"expressionValues": {
":expectedVersion": $util.dynamodb.toDynamoDB($ctx.args.input.expectedVersion)
},
"expressionNames": {
"#version": "version"
}
} )
#set( $newVersion = $ctx.args.input.expectedVersion + 1 )
$util.qr($ctx.args.input.put("version", $newVersion))
$util.qr($ctx.args.input.remove("expectedVersion"))
## [End] Inject @versioned condition.. **
## ~~~
## Update condition if type is @versioned **
#if( $versionedCondition )
$util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression"))
$util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames))
$util.qr($condition.expressionValues.putAll($versionedCondition.expressionValues))
#end
## ~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment