View Source Ash.Query.Aggregate (ash v2.9.11)

Represents an aggregated association value

Link to this section Summary

Link to this section Types

@type kind() :: :custom | :avg | :min | :max | :list | :sum | :first | :count
@type t() :: %Ash.Query.Aggregate{
  authorize?: term(),
  constraints: term(),
  default_value: term(),
  field: term(),
  filterable?: term(),
  implementation: term(),
  kind: term(),
  load: term(),
  name: term(),
  query: term(),
  read_action: term(),
  relationship_path: term(),
  resource: term(),
  type: term(),
  uniq?: term()
}

Link to this section Functions

Link to this function

new!(resource, name, kind, opts \\ [])

View Source
Link to this function

new(resource, name, kind, opts \\ [])

View Source

Create a new aggregate, used with Query.aggregate or Api.aggregate

Options:

  • :path (list of atom/0) - The relationship path to aggregate over. Only used when adding aggregates to a query.

  • :query (term/0) - A base query to use for the aggregate, or a keyword list to be passed to Ash.Query.build/2

  • :field (atom/0) - The field to use for the aggregate. Not necessary for all aggregate types.

  • :default (term/0) - A default value to use for the aggregate if it returns nil.

  • :filterable? (boolean/0) - Wether or not this aggregate may be used in filters.

  • :type (term/0) - A type to use for the aggregate.

  • :constraints (term/0) - Type constraints to use for the aggregate.

  • :implementation (term/0) - The implementation for any custom aggregates.

  • :read_action (atom/0) - The read action to use for the aggregate, defaults to the primary read action.

  • :uniq? (boolean/0) - Wether or not to only consider unique values. Only relevant for count and list aggregates. The default value is false.

  • :authorize? (boolean/0) - Wether or not the aggregate query should authorize based on the target action.
    See Ash.Resource.Dsl.aggregates.count for more information. The default value is true.

Link to this function

new(resource, name, kind, relationship, query, field, default \\ nil, filterable? \\ true, type \\ nil, constraints \\ [], implementation \\ nil, uniq? \\ false, read_action \\ nil, authorize? \\ true)

View Source
This function is deprecated. Use `new/4` instead..
Link to this function

requests(initial_query, can_be_in_query?, authorizing?, calculations_in_query, request_path)

View Source