View Source Backpex.Ecto.Amount.Type (Backpex v0.9.1)

Provides a type for Ecto to store a amount. The underlying data type should be an integer.

Migration

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

Schema

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

schema "my_table" do
  field :amount, Backpex.Ecto.Amount.Type, currency: :EUR, separator: ".", delimiter: ","
end

Summary

Functions

cast(str, opts)

Callback implementation for Ecto.ParameterizedType.cast/2.

dump(int, dumper, opts)

Callback implementation for Ecto.ParameterizedType.dump/3.

init(opts)

Callback implementation for Ecto.ParameterizedType.init/1.

load(int, loader, opts)

Callback implementation for Ecto.ParameterizedType.load/3.

type(params)

Callback implementation for Ecto.ParameterizedType.type/1.