-
Notifications
You must be signed in to change notification settings - Fork 8
/
file.ex
38 lines (33 loc) · 836 Bytes
/
file.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
defmodule CotacoesETL.Schemas.Zamzar.File do
use Ecto.Schema
import Ecto.Changeset
alias __MODULE__
@type t :: %File{
id: integer,
key: String.t(),
size: integer,
name: String.t(),
path: Path.t(),
format: String.t(),
created_at: NaiveDateTime.t()
}
@fields ~w(id key size name format created_at path)a
@primary_key false
embedded_schema do
field(:id, :integer)
field(:key, :string)
field(:size, :integer)
field(:name, :string)
field(:path, :string)
field(:format, :string)
field(:created_at, :naive_datetime)
end
def changeset(file \\ %File{}, attrs) do
cast(file, attrs, @fields)
end
def changeset!(file \\ %File{}, attrs) do
file
|> changeset(attrs)
|> apply_action!(:parse)
end
end