AshAge.Query.Aggregate (AshAge v2.0.0)

Copy Markdown View Source

Translates an Ash.Query.Aggregate.t() (no relationship path) into a Cypher RETURN expression over the matched vertices.

AGE ships the standard Cypher aggregate functions (count, sum, avg, min, max); exists is expressed as count(n) and reduced to a boolean in Elixir, avoiding any dependency on AGE EXISTS {} syntax. Only the field NAME is interpolated — validated as an AGE identifier — never a value.

Summary

Functions

Reduces a decoded agtype scalar to the value Ash expects for the aggregate kind.

Returns the Cypher RETURN expression for {kind, field}.

Functions

decode_value(arg1, count)

@spec decode_value(atom(), term()) :: term()

Reduces a decoded agtype scalar to the value Ash expects for the aggregate kind.

exists -> boolean (raw count > 0); every other kind -> the decoded value as-is (count -> integer, sum/avg -> number, min/max -> the value).

expr(arg)

@spec expr({atom(), atom() | nil, keyword()}) :: String.t()

Returns the Cypher RETURN expression for {kind, field}.

field is required for sum/avg/min/max and for count with uniq?. count/exists over vertices need no field.