Money v1.0.0 Money.Ecto.Type

Provides a type for Ecto usage. The underlying data type should be an integer.

This type expects you to use a single currency. The currency must be defined in your configuration.

config :money,
  default_currency: :GBP

Migration Example

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

Schema Example

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

Summary

Functions

Callback implementation for c:Ecto.Type.cast/1

Callback implementation for c:Ecto.Type.dump/1

Callback implementation for c:Ecto.Type.load/1

Callback implementation for c:Ecto.Type.type/0

Functions

cast(val)

Specs

cast(String.t | integer) :: {:ok, Money.t}

Callback implementation for c:Ecto.Type.cast/1.

dump(int)

Specs

dump(integer | Money.t) :: {:ok, :integer}

Callback implementation for c:Ecto.Type.dump/1.

load(int)

Specs

load(integer) :: {:ok, Money.t}

Callback implementation for c:Ecto.Type.load/1.

type()

Specs

type :: :integer

Callback implementation for c:Ecto.Type.type/0.