April 2019
Beginner to intermediate
244 pages
6h 34m
English
The Query module can be used for more than just reading data. We can use queries in some of the other *all functions we looked at in the last chapter. This allows us to perform update and delete operations on a specific collection of records. Let’s take a look.
In the last chapter, we updated all the timestamps in the artists table with this code:
| | Repo.update_all("artists", set: [updated_at: DateTime.utc_now]) |
In that example, we passed the table name as a String in the first parameter. But if you look at the documentation for update_all you’ll see that this function does not expect a String but rather our new friend Ecto.Queryable. This means that you can also pass in a query, ...
Read now
Unlock full access