ash v1.5.1 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(
  Ash.query(),
  atom(),
  Ash.aggregate_type(),
  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

Limit the results returned from the query

Link to this function

new(resource, api \\ nil)

View Source

Create a new query.

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

Side loads related entities

Link to this function

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

View Source