代码之家  ›  专栏  ›  技术社区  ›  2famous.TV

使用AppSync和Resolver映射模板将数组存储在DynamoDB中(已编辑)

  •  0
  • 2famous.TV  · 技术社区  · 7 年前

    我在用AppSync将数组存储在PutItem上的DynamoDB中遇到了一些问题,这让我抓狂:P

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

    我真的被困在这件事上了,如果能得到任何帮助,我将非常感激!

    这是模板:

      #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 回复  |  直到 7 年前