August 2025
Intermediate to advanced
294 pages
6h 59m
English
Aggregates are a specialized type of calculation, as we’ve seen before. All aggregates are calculations, but a calculation like years_ago in our Album example wasn’t an aggregate.
Aggregates perform some kind of calculation on records in a relationship—it could be a simple calculation like first or count, a more complicated calculation like min or avg (average), or you can even provide a fully custom implementation if the full list of aggregate types[59] doesn’t have what you need.
To start adding aggregates to our Artist resource, we first need to add the aggregates block at the top level of the resource. (You might be sensing a pattern about this, by now.)
| | defmodule Tunez.Music.Artist ... |
Read now
Unlock full access