How to filter associations when preloading them?

I could probably do this with Ecto.Query instead, but I was wondering how I would do it with Ash.Query The scenario, I want to list out all of the Post and I also want to preload the Category association of each post. I also want to filter the categories to only ones that contain a specific category_id.
2 Replies
ZachDaniel
ZachDaniel3y ago
load(category: Ash.Query.filter(Category, id == ^category_id))
load(category: Ash.Query.filter(Category, id == ^category_id))
You can provide a query that will be used when fetching a relationship
Terryble
TerrybleOP3y ago
That worked! Thanks!

Did you find this page helpful?