View Source Money.Ecto.Map.Type (Money v1.13.1)

Provides a type for Ecto to store a multi-currency price. The underlying data type should be a map(JSON). Suitable for databases that do not support composite types, but support JSON (e.g. MySQL).

Migration

create table(:my_table) do
  add :price, :map
end

Schema

schema "my_table" do
  field :price, Money.Ecto.Map.Type
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, Money.t()}

Callback implementation for Ecto.Type.load/1.

@spec type() :: :map

Callback implementation for Ecto.Type.type/0.