Hi,
I want to provide an array with ids of some blobs. I have the following schema:
defmodule News do
…
schema “news” do
…
has_many :documents, News.Document, foreign_key: :news_id
timestamps()
end
…
The document model is:
defmodule News.Document do
@moduledoc false
use Web, :model
schema “news_documents” do
belongs_to :news, News
belongs_to :blob, Blobs.Blob
timestamps()
end
end
and the changeset options:
def changeset(struct, params \ %{}) do
struct
|> cast(params, [:headline, …])
|> validate_required([:headline])
end
Do I need to save the news_documents before or can this be done in one step or what exactly do I have to do?
Thanks.