defmodule App.Catalog.Book do
actions do
create :create do
primary? true
argument :authors, {:array, :uuid} do
allow_nil? false
end
change manage_relationship(:authors, type: :direct_control)
end
end
relationships do
has_many :authorships, App.Catalog.Authorship, sort: [order: :asc]
many_to_many :authors, App.Catalog.UserProfile, join_relationship: :authorships, destination_attribute_on_join_resource: :author_id
end
end
defmodule App.Catalog.Authorship do
attributes do
attribute :order, :integer, allow_nil?: false
end
relationships do
belongs_to :resource, App.Catalog.Resource do
primary_key? true
allow_nil? false
end
belongs_to :author, App.Catalog.UserProfile do
primary_key? true
allow_nil? false
end
end
end
defmodule App.Catalog.Book do
actions do
create :create do
primary? true
argument :authors, {:array, :uuid} do
allow_nil? false
end
change manage_relationship(:authors, type: :direct_control)
end
end
relationships do
has_many :authorships, App.Catalog.Authorship, sort: [order: :asc]
many_to_many :authors, App.Catalog.UserProfile, join_relationship: :authorships, destination_attribute_on_join_resource: :author_id
end
end
defmodule App.Catalog.Authorship do
attributes do
attribute :order, :integer, allow_nil?: false
end
relationships do
belongs_to :resource, App.Catalog.Resource do
primary_key? true
allow_nil? false
end
belongs_to :author, App.Catalog.UserProfile do
primary_key? true
allow_nil? false
end
end
end