When embedding many schemas embeds_many
how can we manage associations with another table?
if i have:
defmodule Order do
use Ecto.Schema
schema "orders" do
field :name, :string
embeds_many :items, Item do
field :name, :string
field :price, :integer
end
end
end
and i want the item_id to be associated to another table. how to manage it? like that?
def change do
create table(:payments) do
add :label, :string
add :item_id, references(:items, on_delete: :delete_all),
null: false
timestamps()
end
create unique_index(:payments, [:label])
create index(:payments, [:item_id])
end