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