April 2019
Beginner to intermediate
244 pages
6h 34m
English
When we first looked at the Repo module in Chapter 1, Getting Started with Repo, we looked at the insert_all and delete_all functions for inserting and deleting data. Ecto provides these functions so you can perform these operations without schemas (which, as we saw in the last section, is sometimes the best approach). When you are working with schemas, Repo has two parallel functions, insert and delete. Let’s take a look at those now. But before we start, let’s run mix ecto.reset once again to get our data back into a clean state.
Here’s a snippet we ran earlier to insert an artists record for John Coltrane using insert_all:
| | Repo.insert_all("artists" ... |
Read now
Unlock full access