Resource interactions

So my simple question is this, how/can one resource interact with another. I have a "bank_account" and bank accounts can have "transactions" when a transaction is pending=false, which is set through the update :cleared action, I want to then add or subtract the amount on that transaction from the bank_account balance. See pseudo code in image attached for what I am envisioning.
No description
3 Replies
ZachDaniel
ZachDaniel•3y ago
You probably want an afteraction hook there ```elixir change fn changeset, -> Ash.Changeset.after_action(changeset, fn changeset, result -> # do your stuff here end) end `` You can use change to add pretty much arbitrary behavior to an action, and you can attach hooks for various lifecycle events, mainly before_transaction -> before_action -> after_action -> after_transaction`
ZachDaniel
ZachDaniel•3y ago
Ash HQ
Guide: Actions
Read the "Actions" guide on Ash HQ
lifeofdan
lifeofdanOP•3y ago
Okay, great. I'll try and take a look at that. Thank you very much. 🙂

Did you find this page helpful?