Ecto.Multi.update_all
You're seeing just the function
update_all
, go back to Ecto.Multi module for more information.
Specs
update_all( t(), name(), Ecto.Queryable.t() | fun(Ecto.Queryable.t()), Keyword.t(), Keyword.t() ) :: t()
Adds an update_all operation to the multi.
Accepts the same arguments and options as Ecto.Repo.update_all/3
does.
Example
Ecto.Multi.new()
|> Ecto.Multi.update_all(:update_all, Post, set: [title: "New title"])
|> MyApp.Repo.transaction()
Ecto.Multi.new()
|> Ecto.Multi.run(:post, fn repo, _changes ->
case repo.get(Post, 1) do
nil -> {:error, :not_found}
post -> {:ok, post}
end
end)
|> Ecto.Multi.update_all(:update_all, fn %{post: post} ->
# Others validations
from(c in Comment, where: c.post_id == ^post.id, update: [set: [title: "New title"]])
end, [])
|> MyApp.Repo.transaction()