Ecto.Multi.insert
You're seeing just the function
insert
, go back to Ecto.Multi module for more information.
Specs
insert( t(), name(), Ecto.Changeset.t() | Ecto.Schema.t() | fun(Ecto.Changeset.t() | Ecto.Schema.t()), Keyword.t() ) :: t()
Adds an insert operation to the multi.
Accepts the same arguments and options as Ecto.Repo.insert/2
does.
Example
Ecto.Multi.new()
|> Ecto.Multi.insert(:insert, %Post{title: "first"})
|> MyApp.Repo.transaction()
Ecto.Multi.new()
|> Ecto.Multi.insert(:post, %Post{title: "first"})
|> Ecto.Multi.insert(:comment, fn %{post: post} ->
Ecto.build_assoc(post, :comments)
end)
|> MyApp.Repo.transaction()