Wrapping Up: Query Your Database

Review what we have learned about querying the database.

We'll cover the following

There’s a lot more that can be said about queries. The Query API is rich and allows us to slice and dice our data any way we want. We’ve provided an introduction to queries and the core of how it works, but we recommend that you spend some time looking at the documentation to see all the things you can do. In particular, look at the documents for the Ecto.Query module to see all the available keywords and look at Ecto.Query.API to see all the utility functions that you can use within queries.

The Query module is powerful, but there are some things that are tedious. First, it seems we always need to add a select clause. Using the same data types repeatedly, as most applications do, could get old in a hurry. Also, when we typecast dynamic values in our queries, it becomes extra work. Fortunately for us, the Schema module can help us with both of these problems, so that will be the next stop on our tour. Read on to see how to make both these problems go away.

Get hands-on with 1200+ tech skills courses.