parse filter with fields from another resource relationship

I'm using Ash.Filter.parse/2 to generate filters using the list syntax, for example:
Ash.Filter.parse(Template, [
or: [
[male_content: [not_equals: "hue"]],
[male_content: [equals: "hua"]]
]
])
Ash.Filter.parse(Template, [
or: [
[male_content: [not_equals: "hue"]],
[male_content: [equals: "hua"]]
]
])
Now, let's say that my Template resource has relationship with another resource School and I want to do a filter expression like this: school.name == "bla" I'm not sure how to express that I'm accessing the name field inside the school relationship field. I tried something like this:
Ash.Filter.parse(Template, [{"school.name", "bla"}])
Ash.Filter.parse(Template, [{"school.name", "bla"}])
But this doesn't work, and at the same time I can't find examples with relationships in the documentation.
1 Reply
Blibs
BlibsOP2y ago
Ha!, I was taking a look into the unit tests and found this one that showed how to do it: https://github.com/ash-project/ash/blob/452ec7df9d40a302206384e5b4c580a02d2c1860/test/filter/filter_test.exs#L595 For reference, the above query can be written like this:
Ash.Filter.parse(FeedbackCupcake.Feedbacks.Template, [school: [name: "bla"]])
Ash.Filter.parse(FeedbackCupcake.Feedbacks.Template, [school: [name: "bla"]])

Did you find this page helpful?