An Ecto type for a set of days, stored in a date[] column (an array
of dates), for the multiple-date picker.
# The migration
add :days, {:array, :date}, default: []
# The schema
field :days, Koyomi.Dates, default: []SQLite has no arrays: ecto_sqlite3 keeps the list in a text column as
a JSON array of ISO dates, which the type reads back the same.
The picker posts the days as a list (days[]), with an empty first
entry so that a form with no day selected still posts the field. The
type drops the empty entries, removes repeated days and sorts the rest,
so ["", "2027-03-05", "2027-03-01", "2027-03-05"] casts to
[~D[2027-03-01], ~D[2027-03-05]]. It also casts a list of Date and
a comma-separated string.
Summary
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.