首页 文章

Dynamodb - 按对象属性查询嵌套在数组中

提问于
浏览
5

我有一个理解的问题,dynamoDb支持嵌套在数组中的对象属性的过滤 . 例:

考虑到我们有一个名为“Street”的表,其中该表中的一个项目(行)具有以下结构:

{
   name: "Street name",
   population: 20,
   houses: 5,
   people: [
      {
          first_name: "FName1",
          last_name: "LName1",
          ... other person's properties
      },
      {
          first_name: "FName2",
          last_name: "LName2",
          ... other person's properties
      },
      {
          first_name: "FName3",
          last_name: "LName3",
          ... other person's properties
      }

      ... etc
   ]
}

我们可以在这种情况下考虑“名称”是dynamodb prefix =,这意味着我们可以根据街道名称进行查询 .

我感兴趣的是,dynamodb支持以下逻辑:“基于具有特定名称的街道进行查询,并为具有以下特定名称的人筛选它 . ”

结果将是这样的(整点是只返回与过滤器匹配的数组中的一个人/对象)

{
   name: "Street nameX",
   population: 20,
   houses: 5,
   people: [
      {
          first_name: "FNameX",
          last_name: "LNameX",
          ... other person's properties
      }
   ]
}

基本上问题是,可以根据嵌套在数组中的对象属性查询后dynamoDb过滤结果 .

Please make a note that I understand that I can achieve this with different table schema - but this example is used for simplicity and it is as it is - focusing question on 'does dynamoDB have support for something like this or not?'.

1 回答

相关问题