Why Use the Composing Queries

Decomposition of queries

With the addition of join, we can start doing more extensive and detailed queries. This is an excellent time to look at one of the features of Query that simplifies working with complicated queries—composability. Ecto allows us to break up large queries into smaller pieces that can be reassembled at will. This makes them easier to work with and will enable us to reuse parts of queries in more than one place.

Let’s say that we wanted to look up all of the albums by Miles Davis. Using joins, this query is straightforward.

Get hands-on with 1200+ tech skills courses.