Reputation: 2930
I am writing an iOS app using AWS DynamoDB. I have a table of notes and each note is associated with a user ID as global secondary index partition key. Is it possible to batch delete all notes associated with a specific user ID?
Upvotes: 1
Views: 2413
Reputation: 2863
As far as I understand, this is your table...
Notes Table: noteID (hash key), userID, [other attributes]
UserNotesGSI: userID (hash key), noteID (range key)
... and you are asking if there is a way to delete all rows in the UserNotesGSI with the same userID.
This is not currently possible, given that you cannot write/delete items from a GSI at all. GSIs are auto-synchronized for you by DynamoDB, based on changes that you make to the main table (Notes
). More details here.
If you look at the BatchWriteItem and DeleteItem methods, you'll notice that you can only specify the table that you want to update/remove items from and not the index, as you can with the Query method. This further backs up my answer.
Upvotes: 3