5avage
5avage
AEAsh Elixir
Created by 5avage on 5/14/2023 in #support
Using ex_money_sql with Ash
SG, thanks
7 replies
AEAsh Elixir
Created by 5avage on 5/14/2023 in #support
Using ex_money_sql with Ash
defmodule Worthy.AshMoney do
use Ash.Type

@impl true
def storage_type, do: :money_with_currency

@impl true
def cast_input(value, _) do
Ecto.Type.cast(Money.Ecto.Composite.Type, value)
end

@impl true
def cast_stored(value, _) do
Ecto.Type.load(Money.Ecto.Composite.Type, value)
end

@impl true
def dump_to_native(value, _) do
Ecto.Type.dump(Money.Ecto.Composite.Type, value)
end
end
defmodule Worthy.AshMoney do
use Ash.Type

@impl true
def storage_type, do: :money_with_currency

@impl true
def cast_input(value, _) do
Ecto.Type.cast(Money.Ecto.Composite.Type, value)
end

@impl true
def cast_stored(value, _) do
Ecto.Type.load(Money.Ecto.Composite.Type, value)
end

@impl true
def dump_to_native(value, _) do
Ecto.Type.dump(Money.Ecto.Composite.Type, value)
end
end
7 replies
AEAsh Elixir
Created by 5avage on 5/14/2023 in #support
Using ex_money_sql with Ash
Thanks, I ended up with this:
7 replies