View Source Periods.Ecto.MapType (Periods v0.1.1)

Provides a type for Ecto to store a Period of time. The underlying data type should be a map(JSON). Suitable for databases that do not support composite types, but support JSON (e.g. MySQL and versions of CockroachDB).

Migration

create table(:timers) do
  add :timer_period, :map
end

Schema

schema "timers" do
  field :timer_period, Periods.Ecto.MapType
end

Summary

Functions

Callback implementation for Ecto.Type.cast/1.

Callback implementation for Ecto.Type.dump/1.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Callback implementation for Ecto.Type.load/1.

Callback implementation for Ecto.Type.type/0.

Functions

Callback implementation for Ecto.Type.cast/1.

@spec dump(any()) :: :error | {:ok, %{required(String.t()) => String.t() | integer()}}

Callback implementation for Ecto.Type.dump/1.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

@spec load(map()) :: {:ok, Periods.Period.t()}

Callback implementation for Ecto.Type.load/1.

@spec type() :: :map

Callback implementation for Ecto.Type.type/0.