0

I have a composite sorting key "123#abc" and I want to remove the item starting with "123".
I can query with such a prefix but I didn't find how to delete an item using a prefix.
AWS doc says I need to provide both partition and sorting keys.
Is it possible to remove an item using a prefix of sort key?

I can query for exact sorting key before removal but I'm curious if delete operation supports this.

1 Answer 1

3

Unfortunately its not supported, for a singleton operations such as DeleteItem, GetItem, PutItem etc... you must know the entire primary key, that is Partition and Sort keys (if a sort key exists).

The only option is to read using Query, then loop the results and call DeleteItem with the keys obtained.

Sign up to request clarification or add additional context in comments.

1 Comment

Probably worth batching deletes using BatchWriteItem for better performance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.