Ecto.Adapter.Transaction

Ecto.Adapter.Transaction behaviour

Specifies the adapter transactions API.

Summary

Callbacks

in_transaction?(repo)

Returns true if the given process is inside a transaction

rollback(repo, value)

Rolls back the current transaction

transaction(repo, options, function)

Runs the given function inside a transaction

Callbacks

in_transaction?(repo)

in_transaction?(repo :: Ecto.Repo.t) :: boolean

Returns true if the given process is inside a transaction.

rollback(repo, value)

rollback(repo :: Ecto.Repo.t, value :: any) :: no_return

Rolls back the current transaction.

The transaction will return the value given as {:error, value}.

See Ecto.Repo.rollback/1.

transaction(repo, options, function)

transaction(repo :: Ecto.Repo.t, options :: Keyword.t, function :: (... -> any)) ::
  {:ok, any} |
  {:error, any}

Runs the given function inside a transaction.

Returns {:ok, value} if the transaction was successful where value is the value return by the function or {:error, value} if the transaction was rolled back where value is the value given to rollback/1.

See Ecto.Repo.transaction/1.

© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ecto/Ecto.Adapter.Transaction.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部