I am trying to update the items in the Dynamodb table. But I am facing a problem so how can I update multiple rows with one key value.
Condition:
set isActive=False where systemId='si11'
+-------------------+----------+----------+
| id(partition_key) | systemId | isActive |
+-------------------+----------+----------+
| 123 | si11 | True |
| 124 | si11 | True |
| 125 | si11 | True |
| 126 | si12 | True |
| 127 | si12 | True |
+-------------------+----------+----------+
So how can I update multiple rows with the key systemId
?
I have a solution but it is not a best practice.
- I will create a GSI index with
ID
(range key) andSystemID
(hash key). - I will query the data with the key systemId.
- Then use the result to update each row with a hash key (
id
).
Please suggest a better solution to this problem.
I only have systemId
for the filter key, so I can only update withsystemId
and I cannot create a GSI index for systemId
because it is not unique.