【发布时间】:2021-04-17 00:29:12
【问题描述】:
我在 DynamoDB 中有来自 Plaid API 的数据转储。每个事务都有 transaction_id、pending(bool) 和 pending_transaction_id(FK 基本上是它替换的旧的挂起事务)
{
"account_id": "acct1", // partition key
"transaction_id": "txn100", // sort key
"category_id": "22001000",
"pending": false,
"pending_transaction_id": "txn1",
"amount": 500,
},
{
"account_id": "acct1",
"transaction_id": "txn1",
"category_id": "22001000",
"pending": true,
"pending_transaction_id": null,
"amount": 500,
},
是否可以在单个查询中只查询尚未永久替换的待处理事务?
换句话说,如果它是关系型数据库,它将是这样的
select * from txn where pending == false and transaction_id not in (select pending_transaction_id from txn)(或任何你喜欢的 CTE 或左加入)。
如何在单个查询中在 dynamo db 中执行此操作?
【问题讨论】:
-
它没有任何帮助。你应该分享dynamodb表方案,以便我们分析。
-
DynamoDB 在设计时并未考虑比较(连接)文档(行)。 stackoverflow.com/questions/36753861/…
-
@MatBailie 谢谢你,Mat,这也是我在看了无数教程后学到的。我将在代码中执行此操作或重新设计表格。谢谢
标签: amazon-dynamodb dynamodb-queries