I want to store data using jsonb that could be either an array or a map. The source data arrives as either an array or a map, and we want to unify this on the server so the front-end can work with a single type. Is there a way/workaround that I can use, store and retrieve both json/map and array types which are valid for the jsonb postgres type?
I have tried to use source: to copy to array type sourced field before calling cast pipeline if I get an array in params:
condition: Map.has_key?(params, "value") && is_list(value)
I am successfully able to save data, but when retrieving from the DB I am getting a cast error
field(:value, :map)
field(:value_array, {:array, :integer}, source: :value)
Note: Ecto version > 3 and postgres 10