Ash.Filter.parse
parse
, go back to Ash.Filter module for more information.
parse(resource, statement, aggregates \\ %{}, calculations \\ %{}, context \\ %{})
View SourceParses a filter statement
See the module documentation for more information on the supported formats for filter statements.
Important
If you are trying to validate a filter supplied from an external/untrusted source,
be sure to use parse_input/2
instead! The only difference is that it only accepts
filters over public attributes/relationships.
Aggregates and calculations
Since custom aggregates/calculations can be added to a query, and they must be explicitly loaded into
a query, the filter parser does not parse them by default. If you wish to support parsing filters
over aggregates/calculations, provide them as the third argument. The best way to do this is to build a query
with them added/loaded, and then use the aggregates
and calculations
keys on the query.
NOTE
A change was made recently that will automatically load any aggregates/calculations that are used in a filter, but if you are using this function you still need to pass them in.
Ash.Filter.parse(MyResource, [id: 1], query.aggregates, query.calculations)