Amplify-cli: How to on delete cascade?

Created on 3 Sep 2020  路  7Comments  路  Source: aws-amplify/amplify-cli

Which Category is your question related to?
API, database

I have one @model type that utilizing several many-to-many connections via a joining model as, for instance, described here.

Now, when I delete a record that belongs to that @model (e.g., Post in the linked example), I have to "manually" delete all records in the joining model. It is very cumbersome as there no way to batch delete them (at least as far I know).

I wonder if there is a way to make my life easier :-) What would be a recommended way to handle it?

enhancement graphql-transformer

Most helpful comment

Any modern database has cascade delete, so having one should be a priority.

All 7 comments

Hi @sakhmedbayev

Currently we don't support cascading delete.

Hi @sakhmedbayev

Currently we don't support cascading delete.

Why not? :-) I think it would be a great feature to add to amplify stack

Hi @sakhmedbayev

I have added this as enhancement, once this is prioritized we will work on this. Feel free to 馃憤 so this gets more visibility. Also you can open a PR for your use case and discuss with the team.

You can use on-delete subscriptions in front-end. And do things.

Cascade delete would be much better implemented with a DynamoDB stream lambda. If there is not a new item in the event, you know it has been deleted and can delete related models. Client-side would not be robust.

An automated back-end solution is better yes.

Any modern database has cascade delete, so having one should be a priority.

Was this page helpful?
0 / 5 - 0 ratings