Wrapping Up

In this chapter, we pushed Ecto a little harder. We started with queries and went deep into the query API. We explored constraints and how Ecto integrates with the database, ensuring that our data is kept clean and consistent. We also built a category layer. Along the way, you learned many things about the Phoenix philosophy:

  • We used Ecto’s query API, which is independent of the repository API, to do some basic queries.

  • We used two forms of queries, a keyword list–based syntax and a pipe-based syntax.

  • We used fragments to pass SQL commands through the query API unchanged.

  • We explored the different ways Ecto queries work with relationships, beyond data preloading.

  • We wrote constraint-style validations for unique indexes and foreign-key ...

Get Programming Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.