ash v0.1.8 Ash.Filter View Source
A filter expression in Ash.
The way we represent filters may be strange, but its important to have it structured,
as merging and checking filter subsets are used all through ash for things like
authorization. The ands
of a filter are not subject to its ors
. The not
of a filter
is also not subject to its ors
.
For instance, if a filter A
has two ands
, B
and C
and two ors
, D
and E
, and
a not
of F, the expression as can be represented as (A or D or E) and NOT F and B and C
.
The filters attributes
and relationships
, are subject to the ors
of that filter.
<and_statements> AND NOT <not_statement> AND (<one_of_or_statements> OR <attributes + relationships>)
This probably needs to be refactored into something more representative of its behavior,
like a series of nested boolean expression structs w/ a reference to the attribute/relationship
it references. Maybe. This would be similar to Ecto's BooleanExpr
structs.
Link to this section Summary
Functions
Parse a filter from a filter expression
Returns true if the second argument is a strict subset (always returns the same or less data) of the first
Link to this section Types
t()
View Sourcet() :: %Ash.Filter{ ands: term(), api: Ash.api(), attributes: Keyword.t(), errors: [String.t()], impossible?: boolean(), not: %Ash.Filter{ ands: term(), api: term(), attributes: term(), errors: term(), impossible?: term(), not: term(), ors: term(), path: term(), relationships: term(), requests: term(), resource: term() } | nil, ors: [ %Ash.Filter{ ands: term(), api: term(), attributes: term(), errors: term(), impossible?: term(), not: term(), ors: term(), path: term(), relationships: term(), requests: term(), resource: term() } | nil ], path: [atom()], relationships: map(), requests: [Ash.Engine.Request.t()], resource: Ash.resource() }
Link to this section Functions
parse(resource, filter, api, path \\ [])
View Sourceparse(Ash.resource(), Keyword.t(), Ash.api(), relationship_path :: [atom()]) :: t()
Parse a filter from a filter expression
The only rason to pass api
would be if you intend to leverage
any engine requests that would be generated by this filter.
Returns true if the second argument is a strict subset (always returns the same or less data) of the first