Aurora. Uix. Integration. Ash. QueryParser
(Aurora UIX v0.1.4-rc.2)
Copy Markdown
Parses and applies query options to Ash queries.
Transforms keyword list options into Ash query operations, supporting filtering, sorting, preloading, and other query modifications. Handles various comparison operators and automatically translates them to Ash-compatible formats.
Key Features
- Supports
:order_byfor sorting - Handles
:whereclauses with multiple operators (:eq,:in,:between,:like,:ilike,:gte,:lte) - Supports
:preloadfor loading associations - Automatically translates operation aliases (
:ge,:le,:equal_to) - Comma-separated string parsing for
:inoperations
Key Constraints
- Only processes
:order_by,:where, and:preloadoptions; other options are ignored - The
:inoperator expects either a list or comma-separated string - The
:betweenoperator requires start and end values
Summary
Functions
Parses and applies query options to an Ash query.
Functions
@spec parse( Ash.Query.t(), keyword() ) :: Ash.Query.t()
Parses and applies query options to an Ash query.
Parameters
query(Ash.Query.t()) - The base Ash query to modify.opts(keyword()) - Options::order_by(term()) - Sorting specification passed toAsh.Query.sort/2.:where(list()) - List of filter clauses.:preload(term()) - Associations to load.
Returns
Ash.Query.t() - The modified query with applied options.
Examples
iex> query = Ash.Query.new(MyApp.Post)
iex> parse(query, where: [{:status, :eq, "published"}], order_by: [inserted_at: :desc])
#Ash.Query<...>
iex> query = Ash.Query.new(MyApp.User)
iex> parse(query, where: [{:age, :between, 18, 65}])
#Ash.Query<...>
iex> query = Ash.Query.new(MyApp.Product)
iex> parse(query, where: [{:category, :in, "electronics,books"}])
#Ash.Query<...>