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
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I imagine you could make a trigger that checks if the |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
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