How to add Current Date in putItem in VTL

瘦欲@ 提交于 2019-12-11 10:33:08

问题


{
  "version": "2017-02-28",
  "operation": "PutItem",
  "key": {
    "id": $util.dynamodb.toDynamoDBJson($util.autoId()),
    "createdDate":$core_v2_utility.CurrentDate
  },
  "attributeValues": $util.dynamodb.toMapValuesJson($ctx.args.input),
  "condition": {
    "expression": "attribute_not_exists(#id)",
    "expressionNames": {
      "#id": "id",
      "#createdDate":"createdDate",
    },
   },
}

I have been trying to add a createDate into DynamoDB using VTL.I am finding error with $core_v2_utility.CurrentDate


回答1:


AWS AppSync does not have a $core_v2_utility.CurrentDate. Did you mean to use one of the time helpers? $util.time.nowFormatted("yyyy-MM-dd HH:mm:ssZ") gives you the current date and time in UTC.



来源:https://stackoverflow.com/questions/53625805/how-to-add-current-date-in-putitem-in-vtl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!