currency v1.0.0 Currency.Ecto

Provides a custom type for use in an Ecto schema to use Currency as a field type.

Usage:

Schema:

defmodule Thing do
  use Ecto.Schema

  schema "things" do
    field :name, :string
    field :cost, Currency.Ecto
  end
end

Migration:

def change do
  execute "CREATE TYPE currency AS (
      units integer,
      precision integer,
      currency varchar
    );
  "

  create table(:things) do
    add :name, :string
    add :cost, :currency
  end
end

Link to this section Summary

Link to this section Functions