如何在VTL中的putItem中添加当前日期 [英] How to add Current Date in putItem in VTL

查看:106
本文介绍了如何在VTL中的putItem中添加当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{
  "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",
    },
   },
}

我一直在尝试使用VTL将createDate添加到DynamoDB中.我发现$ core_v2_utility.CurrentDate错误

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

推荐答案

AWS AppSync没有$core_v2_utility.CurrentDate.您是要使用时间帮手? $util.time.nowFormatted("yyyy-MM-dd HH:mm:ssZ")以UTC给出当前日期和时间.

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.

这篇关于如何在VTL中的putItem中添加当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆