Replies: 1 comment
-
Let's say I want to delete a model instance (DELETE /books/1), but there are foreign key references to book in some other table. I want to clean those up with a lifecycle hook. I can't safely do it in PRECOMMIT because the ORM will complain the moment the delete SQL command is flushed to the database (prior to the commit). I could do the cleanup in a PRESECURITY hook. However, maybe those references are needed by the security check to evaluate its logic. Hence, the best place to do something like this kind of foreign key cleanup is in a PREFLUSH hook. Here is an example model: And here is the example hook: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@aklish You explained briefly about this phase in this pull request:
This phase is also useful if you want to clean up references prior to a model deletion in a lifecycle hook - but don't want it to happen prior to security checks.
Could you please provide us with some more detail of it? An example would be very helpful. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions