I have a schema:
schema "assets" do
field :title, :string
field :description, :string
field :files, :map
end
I don’t want to use a embedded schema for :files
, because there may be a large list of optional fields here. So is it good way to update my :files
JSONB document?
Resources.update_asset(asset, %{files: Map.merge(asset.files, new_params)})
It works, but looks not elegant. Actually there is not even a PostgreSQL jsonb concatenate function ||
used, because my data is concatenated at the Elixir level.