Using the Repository to Add Data
With our database ready, we can begin to persist our User structs. Let’s hop into an IEx shell and create the users that we previously hard-coded in our in-memory repository. We’ll worry about hashing the password later.
This Is a Bad Idea | |
---|---|
You don’t want to store plain-text passwords into your database! We’ll temporarily save plain-text passwords only as an intermediate step toward a more sophisticated user authentication system. |
Spin up your console with iex -S mix, and insert some data:
| iex> alias Rumbl.Repo |
| iex> alias Rumbl.User |
| |
| iex> Repo.insert(%User{ |
| ...> name: "José", username: ... |
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.