简体   繁体   English

AWS CDK 步骤 Function 任务 - 在 DynamoPutItem 任务中包含对象列表

[英]AWS CDK Step Function Task - Include list of objects in DynamoPutItem task

I'm trying to use the DynamoPutItem task to put an entry which includes a list of objects as one of its attributes.我正在尝试使用DynamoPutItem任务来放置一个条目,其中包含一个对象列表作为其属性之一。 I can't find any examples of this being done online so I'm wondering if it is even possible?我找不到任何在线完成此操作的示例,所以我想知道是否有可能?

This CDK issue seems to be talking about the same thing but that won't work for me, I'm wondering is that only good for lists of strings not objects?这个 CDK问题似乎在谈论同样的事情,但这对我不起作用,我想知道它只适用于字符串列表而不是对象吗?

Here is a simplified example of an item I'm trying to put to DDB:这是我尝试放入 DDB 的项目的简化示例:

{
  'someKey': 'This will be fine',
  'anotherKey': [
    {
      'ohoh': 'This object and the list it belongs will cause an error'
    }
  ]
}

I've tried numerous combinations of DynamoAttributeValue and JsonPath to no avail:(我尝试了DynamoAttributeValueJsonPath的多种组合都无济于事:(

Here is an example of some code that I've tried:这是我尝试过的一些代码的示例:

new DynamoPutItem(this, 'some id here', {
  item: {
    // this will be fine
    someKey: DynamoAttributeValue.fromString(JsonPath.stringAt('$.someKey'),
    // this will cause an error
    anotherKey: DynamoAttributeValue.listFromJsonPath(JsonPath.stringAt('$.anotherKey')),
  },
  table: myTable,
}

and the error it throws: The field "ohoh" is not supported by Step Functions及其抛出的错误: The field "ohoh" is not supported by Step Functions

If I read the docu here it seems like you need to use:如果我在这里阅读文档,您似乎需要使用:

DynamoAttributeValue.listFromJsonPath(value: anotherKey)

Did you ever find a solution for this?你有没有找到解决方案? I'm stuck with the same problem...我遇到了同样的问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM