我将以下数据存储在名为 的 DynamoDB 表中elo-history
。
{
"gameId": "chess",
"guildId": "abc123",
"id": "c3c640e2d8b76b034605d8835a03bef8",
"recordedAt": 1621095861673,
"results": [
{
"oldEloRating": null,
"newEloRating": 2010,
"place": 1,
"playerIds": [
"abc1"
]
},
{
"oldEloRating": null,
"newEloRating": 1990,
"place": 2,
"playerIds": [
"abc2"
]
}
],
"versus": "1v1"
}
我有 2 个索引,guildId-recordedAt-index
并且gameId-recordedAt-index
. 论文允许我查询这些字段。
我正在尝试为results[].playerIds[]
. 我希望能够对记录进行查询,playerId=abc1
并像 guildId 和 gameId 一样对这些记录进行排序。DynamoDB 是否支持类似的东西?我是否需要重组数据或以两种不同的格式保存数据以支持这种类型的查询?
像这样的东西。player-elo-history
除表外还调用了新elo-history
表。这将按 playerId 存储游戏列表
{
"id": "abc1",
"gameId": "chess",
"guildId": "abc123",
"recordedAt": 1621095861673,
"results": [
[
{
"oldEloRating": null,
"newEloRating": 2010,
"place": 1,
"playerIds": [
"abc1"
]
},
{
"oldEloRating": null,
"newEloRating": 1990,
"place": 2,
"playerIds": [
"abc2"
]
}
]
]
}
{
"id": "abc2",
"gameId": "chess",
"guildId": "abc123",
"recordedAt": 1621095861673,
"results": [
[
{
"oldEloRating": null,
"newEloRating": 2010,
"place": 1,
"playerIds": [
"abc1"
]
},
{
"oldEloRating": null,
"newEloRating": 1990,
"place": 2,
"playerIds": [
"abc2"
]
}
]
]
}