通过深层嵌套值过滤DynamoDB扫描

时间:2016-11-09 17:52:09

标签: javascript amazon-dynamodb aws-sdk

我有一个相当嵌套的对象结构,我想在dynamodb中扫描。它看起来像这样:

ProductGroup
| id
| customerId
| serviceId
| [assignedAssets] (An Array of Assets objects, each of which has the following)
| | id
| | sku
| | [instances] (an array of Instance objects, each of which has the following)
| | | id
| | | friendlyName

如果我想找到包含ID为的实例的ProductGroup,比如" instance10",我可以使用in=运算符的某种组合利用Dynamo的过滤表达式?如果它有任何区别,请使用Javascript SDK。

1 个答案:

答案 0 :(得分:0)

如果你也知道资产ID,而不是使用数组,你可以使用地图在服务器端进行过滤。

ProductGroup
| id
| customerId
| serviceId
| {assignedAssets} (A Map of Asset objects, where the key is id)
| | id
| | sku
| | {instances} (A Map of Instance objects, where the key is the id)
| | | id
| | | friendlyName

此处,过滤器表达式为attribute_exists(assignedAssets.#assignedAssetId.instances.#instanceId)