Ecto.Multi.delete
You're seeing just the function
delete
, go back to Ecto.Multi module for more information.
Specs
delete( t(), name(), Ecto.Changeset.t() | Ecto.Schema.t() | fun(Ecto.Changeset.t() | Ecto.Schema.t()), Keyword.t() ) :: t()
Adds a delete operation to the multi.
Accepts the same arguments and options as Ecto.Repo.delete/2
does.
Example
post = MyApp.Repo.get!(Post, 1)
Ecto.Multi.new()
|> Ecto.Multi.delete(:delete, post)
|> 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.delete(:delete, fn %{post: post} ->
# Others validations
post
end)
|> MyApp.Repo.transaction()