How To: Atomic update with a where clause
I'm trying to implement this workflow:
Update a timestamp atomically on an existing record if the new timestamp is greater than the old one, and the old one hasn't changed while im updating it(optimistic update).
I know atomics just dropped on Ash core so wondering if this could be achieved with it.
This is the ash action in question:
5 Replies
Basically want to do something like this:
That should do it 🙂
That works @Zach Daniel You're the best!
How would you combine this with another attribute? Like say I want the
invoice_status
attribute to only update if the atomic last_invoice_event_ts
is updated? Can that even work? Do I have to dip into a custom action / change for that?
Something like so:
You can get another field 🙂 You can't get the "new value", but you can get the old value and the argument
Thanks that works! For posterity, This is my change module updating two values atomically: