ยฉ 2026 Hedgehog Software, LLC
product
many_to_many
tags
defmodule App.Shop.Product do [...] relationships do many_to_many :tags, App.Shop.Tag do through App.Shop.ProductTag source_attribute_on_join_resource :product_id destination_attribute_on_join_resource :tag_id end end actions do defaults [:read] create :create do primary? true argument :tags, {:array, :map} argument :add_tag, :map do allow_nil? false end change manage_relationship(:tags, type: :append_and_remove, on_no_match: :create) change manage_relationship(:add_tag, :tags, type: :create) end update :update do primary? true argument :tags, {:array, :map} argument :add_tag, :map do allow_nil? false end change manage_relationship(:tags, type: :append_and_remove, on_no_match: :create) change manage_relationship(:add_tag, :tags, type: :create) end end code_interface do define_for App.Shop define :create define :read define :update end end
iex(1)> App.Shop.Product.create!(%{name: "Banana"}, add_tag: %{name: "Yellow"}) ** (Ash.Error.Unknown) Unknown Error * %NimbleOptions.ValidationError{message: "unknown options [:add_tag], valid options are: [:upsert?, :upsert_identity, :upsert_fields, :internal?, :timeout, :tracer, :verbose?, :action, :authorize?, :stacktraces?, :tenant, :actor, :after_action, :return_notifications?, :notification_metadata]", key: [:add_tag], value: nil, keys_path: []} (ash 2.14.18) lib/ash/api/api.ex:2179: Ash.Api.unwrap_or_raise!/3