I am using Ecto only for schema and changeset. I store my values within redis as JSON blobs. But I am unable to decode the blob into a schema using Timex.Ecto.Time
defmodule Test.Value do
use Ecto.Schema
@derive {Poison.Encoder, except: [:__meta__]}
@primary_key {:id, :binary_id, autogenerate: false}
schema("latest") do
field :timestamp, Timex.Ecto.DateTime
field :value, :boolean
end
end
In my (custom) Repo
defp serialize(data) do
data |> Poison.encode!
end
defp deserialize(model, data) do
model.__struct__
|> Ecto.Changeset.cast(Poison.decode!(data), model.__schema__(:fields))
|> Ecto.Changeset.apply_changes()
end
I am using
Ecto
only for schema and changeset. I store my values within redis as JSON blobs. But I am unable to decode the blob into a schema usingTimex.Ecto.Time
In my (custom) Repo
and I am getting
timestamp: nil
. For example: