Better Data Access with Composable Queries
summary
Decomposes Ecto.Query into small composable functions that return a queriable, showing concrete helpers like joins, subqueries and named bindings so callers can write pipelines such as from(:bison) |> by_state_code |> with_last_appointment. Demonstrates using has_named_binding to avoid duplicate joins, creating a base query with soft-delete and running live code where tests pass. Recommends integration tests that assert which records do or don’t return, and positions this pattern as practical for reporting layers.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 4:45Legacy reporting problems
- 10:12Composable Ecto queries
- 18:54Reusable query functions
- 22:46Named bindings in joins
- 28:15Base queries and soft deletes
- 31:31Testing query builders
- 33:17Key takeaways
- 35:30Q&A
related talks
26mComposable Queries with Ecto
30mDiving into Ecto.Query
41mEcto: A language integrated query for Elixir
35mElixir's Ecto: Functional Relational Data Access Done Right
48mCompositional, Expressive, Performant Database Queries: Choose 3
37mLeveling Up With Ecto
23mWith Great Composition Comes Great Responsibility
41mEmbrace the Database With Ecto
