Hi every body i am working on dynamodb and very new to this technology i studied it with detail and i have been stuck in a problem since last week and could not found any help. i want to use the partition key of Global secondary index to update and delete item rather than using partition key of Base table. i could not get any way to update and delete items in dynamodb using partition key Global secondary index.
DynamoDB dyn = new DynamoDB(dynamoDB);
Table table = dyn.getTable(tableName);
com.amazonaws.services.dynamodbv2.document.Index index =
table.getIndex(indexName);
index.updateItemRequest(); // not supported
You cannot delete an item using the key of the Global Secondary Index (GSI).
In order to delete an item you need the table's key (partition key + sorting key). One way to get this key is by querying the GSI.
So: GSI Key -> query on GSI -> Table Key -> Delete
.
Update works the same way: GSI Keys -> query on GSI -> Table Key -> Update
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With