Ash.Query.build
You're seeing just the function
build
, go back to Ash.Query module for more information.
Specs
build(Ash.Resource.t(), Ash.Api.t() | nil, Keyword.t()) :: t()
Builds a query from a keyword list.
This is used by certain query constructs like aggregates. It can also be used to manipulate a data structure before passing it to an ash query. It allows for building an entire query struct using only a keyword list.
For example:
Ash.Query.build(MyResource, filter: [name: "fred"], sort: [name: :asc], load: [:foo, :bar], offset: 10)
If you want to use the expression style filters, you can use expr/1
. Be sure to require Ash.Query
first,
or import it. Consider importing only the expr/1
macro if you do that
For example:
import Ash.Query, only: [expr: 1]
Ash.Query.build(Myresource, filter: expr(name == "marge"))
Supported keys:
filter
- filter keyword/expr or%Ash.Filter{}
sort
- sort keywordlimit
- integer limitoffset
- integer offsetload
- keyword/list of atoms to loadaggregate
-{name, type, relationship}
aggregate
-{name, type, relationship, query_in_build_format}
calculate
-{name, module_and_opts}
calculate
-{name, module_and_opts, context}
distinct
- list of atomscontext: %{key: value}