使用带有解析器映射模板的AppSync在DynamoDB中存储阵列(已编辑)

时间:2018-07-13 13:44:30

标签: amazon-dynamodb aws-appsync

我在使用AppSync在PutItem上的DynamoDB中存储数组时遇到了一些麻烦,这让我发疯:P

问题是当我运行$util.dynamodb.toMapValuesJson时,我从GraphQl传递的数组消失了。我在做什么错了?

我真的很坚持这一点,非常感谢我能提供的任何帮助!

这是模板:

  #set($failing_list = [ "foo", 123, { "bar" : "baz" } ])

  {
    "version" : "2017-02-28",
    "operation" : "PutItem",
    "key": {
      "userId": { "S": "$ctx.args.input.email" },
      "createdAt": { "N": "$util.time.nowEpochMilliSeconds()" }
    },
    "data" : {
      "test": $util.dynamodb.toMapValuesJson({
        "working_list": [ "foo", 123, { "bar" : "baz" } ],
        "failing_list": $failing_list
      })
    }
  }

这是结果:

  {
    version: '2017-02-28',
    operation: 'PutItem',
    key: {
      userId: { S: 'xxxxxxxxxxxx' },
      createdAt: { N: '1531521284789' }
    },
    data: {
      test: {
        working_list: {
          L: [ { S: 'foo' }, { N: '123' }, { M: { bar: { S: 'baz' } } } ]
        },
        failing_list: {
          M: { L: { L: [ { M: { map: { M: {} } } }, { M: { map: { M: {} } } }, { M: { map: { M: {} } } } ] } }
        }
      }
   }
  }

0 个答案:

没有答案