ash v1.7.0 Ash.Query View Source

Utilties around constructing/manipulating ash queries.

Ash queries are used for read actions and side loads, and ultimately map to queries to a resource's data layer.

Link to this section Summary

Link to this section Types

Specs

t() :: %Ash.Query{
  aggregates: term(),
  api: term(),
  data_layer_query: term(),
  errors: term(),
  filter: term(),
  limit: term(),
  offset: term(),
  resource: term(),
  side_load: term(),
  sort: term(),
  valid?: term()
}

Link to this section Functions

Link to this function

aggregate(query, name, type, relationship, agg_query \\ nil)

View Source

Specs

aggregate(
  t() | Ash.resource(),
  atom(),
  Ash.aggregate_kind(),
  atom() | [atom()],
  Ash.query() | nil
) :: t()

Adds an aggregation to the query.

Aggregations are made available on the aggregates field of the records returned

The only aggregate available currently is a count aggregate. They filter option accepts either a filter or a keyword list of options to supply to build a limiting query for that aggregate. However, currently only filters are accepted.

Link to this function

build(resource, api \\ nil, keyword)

View Source

Specs

build(Ash.resource(), Ash.api() | nil, Keyword.t()) :: t()
Link to this function

do_validate_side_load(resource, query, path)

View Source

Specs

filter(t() | Ash.resource(), nil | false | Ash.filter() | Keyword.t()) :: t()

Specs

limit(t() | Ash.resource(), nil | integer()) :: t()

Limit the results returned from the query

Specs

load(t(), atom() | [atom()] | Keyword.t()) :: t()
Link to this function

new(resource, api \\ nil)

View Source

Create a new query.

Specs

offset(t() | Ash.resource(), nil | integer()) :: t()

Skip the first n records

Set the query's api, and any side loaded query's api

Link to this function

side_load(query, statement)

View Source

Specs

side_load(t() | Ash.resource(), Ash.side_loads()) :: t()

Side loads related entities

Specs

sort(t() | Ash.resource(), Ash.sort()) :: t()

Specs

unset(Ash.resource() | t(), atom() | [atom()]) :: t()
Link to this function

validate_side_load(resource, side_loads, path \\ [])

View Source