View Source Money.Ecto.NumericCurrency.Type (Money v1.12.4)

Provides a type for Ecto to store a currency. The underlying data type is a integer.

migration

Migration

create table(:my_table) do
  add :currency, :integer
end

schema

Schema

schema "my_table" do
  field :currency, Money.Ecto.NumericCurrency.Type
end

Link to this section 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.

Link to this section Functions

@spec cast(Money.t() | String.t() | atom() | integer()) :: {:ok, atom()} | :error

Callback implementation for Ecto.Type.cast/1.

@spec dump(atom()) :: {:ok, 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(integer()) :: {:ok, atom()}

Callback implementation for Ecto.Type.load/1.

@spec type() :: :integer

Callback implementation for Ecto.Type.type/0.