Compose Queries with Functions

Learn how to compose queries with functions.

Composable functions

One of the critical superpowers of Ecto is the ability to make queries from composable functions. This makes the query fragments reusable and substantially improves readability.

For example, with just a slight tweak, we can take the albums_by_miles query we’ve been working with and put it into a function that will create a query for any artist’s name.

Get hands-on with 1200+ tech skills courses.