W3cubDocs

/Phoenix

Ecto.Adapter.Transaction behaviour

Specifies the adapter transactions API.

Summary

Types

adapter_meta()

Callbacks

in_transaction?(adapter_meta)

Returns true if the given process is inside a transaction

rollback(adapter_meta, value)

Rolls back the current transaction

transaction(adapter_meta, options, function)

Runs the given function inside a transaction

Types

adapter_meta()

adapter_meta() :: Ecto.Adapter.adapter_meta()

Callbacks

in_transaction?(adapter_meta)

in_transaction?(adapter_meta()) :: boolean()

Returns true if the given process is inside a transaction.

rollback(adapter_meta, value)

rollback(adapter_meta(), 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(adapter_meta, options, function)

transaction(adapter_meta(), 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.

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