bahalperin
Explore posts from serversAEAsh Elixir
•Created by bahalperin on 7/13/2023 in #support
Calculations Using Relationships
I'm writing a simple chat app to try to learn Ash. I have models like below and I'd like to write an
:unread_count
calculation on the Channel
. It would take the current user as the actor and find the associated member of the channel, use that :last_read_at
time to filter down the messages associated with the channel to ones that has a :created_at
after that time, and count them.
I'm having a hard time figuring out how to do that based on the examples.
What I think I want is something like:
Assuming :current_member
is another calculation that exists to get the member associated with the current user.
Apologies if I'm thinking about this in the completely wrong way and thanks in advance for the help!
Models
11 replies