I have a data dump from Plaid API in DynamoDB. Each transaction has transaction_id, pending(bool), and pending_transaction_id (the FK basically to the older pending transaction it replaces)
{
"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,
},
Is it possible to query in a single query only pending transactions that don't have a permanent replacement yet?
In other words, if it was relational DB it would be along the lines
select * from txn where pending == false and transaction_id not in (select pending_transaction_id from txn)
(or whatever flavor of CTE or left join you prefer).
How do I do this in dynamo db in a single query?