Ash FrameworkAF
Ash Framework4w ago
6 replies
sevenseacat

Filtering by an embedded array attribute's resource value?

I can write a filter that filters by an attribute of an embedded resource using get_path, eg.

Ash.Query.filter(query, get_path(^ref(embed_atom), [^field_atom]) == ^value)


But this doesn't seem to work if the embedded attribute is an array of resources.

eg. resource Ingredient
has an attribute -> attribute :effects, {:array, __MODULE__.Effect}, allow_nil?: false, default: []
and I want to select Ingredients if any of their effects matches a filter.

exists
was my first thought but that only works for relationships (or plain resources), not attributes?
Was this page helpful?