0

guys, I'm kind of new to dynamo DB. I'm working on demo project in which I'm using dynamo as my DB. and I'm using vogel as it's data mapper.

Now I was going through the vogel documentation and there it was written if I had to delete I needed to provide the hash key and if I have specified a range key then that is to be provided also.

for example, if I have a hash key say id then when I'm deleting then I need to provide that id and if I have a range key say user id then that is also needed while deleting the item. Delete Documentation in Vogel => Deleting in Vogel

Now my question if I need to delete an item on the basis of something which is neither a hash key nor a range key e.g we have a requirement that we need to delete all the posts of a user whose account status is deleted where the status attribute is not a hash key nor a range key How will I achieve this Thanks

Gardezi
  • 2,692
  • 2
  • 32
  • 62

1 Answers1

0

As per DynamoDB design, the update and delete item must have hash key and range key (if available). The delete item can't be performed without having the key attributes.

In the above case, it has to be done in two steps.

1) Scan/Query the table to get the required key values

2) Perform delete using the key values. ConditionExpression can be used to provide additional condition if required.

ConditionExpression - A condition that must be satisfied in order for a conditional DeleteItem to succeed.

notionquest
  • 37,595
  • 6
  • 111
  • 105