ash_postgres/lib/custom_aggregate.ex
Zach Daniel 68c6d7aaf8 improvement: better error messages from mix tasks
fix: various broken behavior from new aggregate work
improvement: validate that references refer to relationships

closes #99
2022-12-10 15:59:50 -05:00

26 lines
616 B
Elixir

defmodule AshPostgres.CustomAggregate do
@moduledoc """
A custom aggregate implementation for ecto.
"""
@doc """
The dynamic expression to create the aggregate.
The binding refers to the resource being aggregated,
use `as(^binding)` to reference it.
For example:
Ecto.Query.dynamic(
[],
fragment("string_agg(?, ?)", field(as(^binding), ^opts[:field]), ^opts[:delimiter])
)
"""
@callback dynamic(opts :: Keyword.t(), binding :: integer) :: Ecto.Query.dynamic()
defmacro __using__(_) do
quote do
@behaviour AshPostgres.CustomAggregate
end
end
end