July 2018
Intermediate to advanced
574 pages
14h 7m
English
Our ElixirDrip project allows users to safely store their media, and eventually share it with other users. Therefore, we need to have a way to represent users and media as database tables.
To help developers with this, Ecto has the schema construct. Its purpose is to establish a mapping between any information stored in the database and its representation in Elixir data structures.
Let's define the schema to represent the users' media:
$ cat apps/elixir_drip/lib/elixir_drip/storage/media.exdefmodule ElixirDrip.Storage.Media do use Ecto.Schema schema "storage_media" do field :user_id, :id field :file_name, :string field :full_path, :string field :file_size, :integer field :metadata, :map, default: %{} field :encryption_key, :string ...Read now
Unlock full access