Request Mapping Template - Storing the user's identity
## [Start] Prepare DynamoDB PutItem Request. ** | |
$util.qr($context.args.input.put("createdAt", $util.time.nowISO8601())) | |
$util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) | |
$util.qr($context.args.input.put("__typename", "Restaurant")) | |
## This line adds the userId, accessed from the $ctx.identity variable | |
$util.qr($context.args.input.put("userId", $ctx.identity.sub)) | |
{ | |
"version": "2017-02-28", | |
"operation": "PutItem", | |
"key": { | |
"id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId())) | |
}, | |
"attributeValues": $util.dynamodb.toMapValuesJson($context.args.input), | |
"condition": { | |
"expression": "attribute_not_exists(#id)", | |
"expressionNames": { | |
"#id": "id" | |
} | |
} | |
} | |
## [End] Prepare DynamoDB PutItem Request. ** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment