OOL - Optimistic object locking implementation #182
|
Hi! I'm new to this lib and I'm wondering if that is possible to implement OOL with it? I saw
|
Answered by
wesleykendall
Nov 5, 2024
Replies: 2 comments 1 reply
|
I imagine you could make a trigger that checks if the |
0 replies
|
Typical OOL-protected model should follow the following logic:
I see how 1 & 2 can be implemented but can't find solution for 3 & 4. Is that even possible? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For 3) and 4), one pattern is the official interface pattern in pgtrigger. In other words, force every update in your app to go through the same interface(s) so that the version field is always provided.
Briefly, the official interface pattern is to block all updates on the table with protection triggers and decorator your official interfaces with
@pgtrigger.ignore("protection_trigger_name").Hope that helps. I'm happy to accept more examples in the docs for patterns like these. There's many useful patterns like these you can apply with both triggers and pgtrigger's ability to ignore execution of triggers from the application