July 2017
Intermediate to advanced
284 pages
6h 45m
English
If you want to create persistent entities, you need to show Blacksmith how to save single entities and lists of entities. For example, you might want to save records using Ecto, a persistence engine for Elixir. Here’s how you’d go about it. Let’s say you’re starting with an Ecto schema, like this:
| | ~~~ |
| | defmodule User do |
| | use Ecto.Model |
| | |
| | schema "users" do |
| | field :first_name, :string |
| | field :last_name, :string |
| | field :email, :string |
| | end |
| | end |
| | ~~~ |
We’re creating a simple database-backed entity. The database schema and model will both have corresponding fields.
Next, we create a Forge. Our Forge will specify the User struct for Ecto, as well as a couple of functions that Ecto could use to save one or many entities, ...
Read now
Unlock full access