What is an easy and quick way to encode some Ecto struct from a query in IEx? I'm not looking for how to implement @derive
in my application code, just a quick way to dump to JSON quickly pull some data.
I found the following worked for me. One needs to drop :__meta__
and any not loaded associations.
Repo.all(Event) |> Enum.map(&(Map.from_struct(&1) |> Map.drop([:__meta__]))) |> Jason.encode!()