schema "rates" domany_to_many :offers, Offer, join_through: "offers_rates"end
schema "offers" domany_to_many :rates, Rate, join_through: "offers_rates"end
Enum.map rates, fn (rate) ->Offer.changeset(%Offer{rates: [rate]}, %{shipment_id: rate.shipment_id, percentage: 1.05})|> Repo.insert!()end
offers = Repo.preload(shipment, offers: :rates)
%Offer{rates: []}
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/90e0e96e-a6ca-4111-b4cc-e9d180b99b6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
SELECT r0."id", *snip*, o1."offer_id" FROM "rates" AS r0 INNER JOIN "offers_rates" AS o1 ON o1."offer_id" = ANY($1) WHERE (o1."rate_id" = r0."id") ORDER BY o1."offer_id" [[<<163, 3, 242, 94, 74, 2, 77, 110, 159, 78, 123, 64, 97, 42, 5, 33>>]]
SELECT * FROM rates INNER JOIN offers_rates ON offers_rates.offer_id='a303f25e-4a02-4d6e-9f4e-7b40612a0521' WHERE offers_rates.rate_id = rates.id;
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/589094f3-2694-4b15-9d39-03d8e4869682%40googlegroups.com.
def change docreate table(:offers, primary_key: false) doadd :id, :binary_id, primary_key: trueadd :percentage, :float, null: falseadd :shipment_id, references(:shipments, on_delete: :delete_all, type: :binary_id), null: falsetimestampsendcreate index(:offers, [:shipment_id])end