Reputation: 1755
I have a DynamoDB table which is tracking two IDs:
UNIQUE
constraint if this was SQL).This table has a Global Secondary Index, with the partition key set to B and the sort key set to A; acting as a reverse lookup for the records that are in the main table.
I would like to put a record into this main table, but only do so if there's no record with B already present. Specifically, I'd like to:
Is this possible using DynamoDB transactional writes? From looking at the documents, there is a ConditionCheck operation that could be useful here; but as far as I can tell, it doesn't seem possible to run a condition check on a GSI, or am I missing something here?
Upvotes: 3
Views: 1656
Reputation: 7132
You cannot do transactions that include GSIs. I would recommend you follow the design of this blog post, putting an entry in the base table with B as the primary key to enable the uniqueness check (maybe then using it instead of a GSI):
Upvotes: 2