View Source Ecto.Adapter.Transaction behaviour (Ecto v3.12.3)

Specifies the adapter transactions API.

Summary

Callbacks

Returns true if the given process is inside a transaction.

Rolls back the current transaction.

Runs the given function inside a transaction.

Types

@type adapter_meta() :: Ecto.Adapter.adapter_meta()

Callbacks

Link to this callback

in_transaction?(adapter_meta)

View Source
@callback in_transaction?(adapter_meta()) :: boolean()

Returns true if the given process is inside a transaction.

Link to this callback

rollback(adapter_meta, value)

View Source
@callback 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.

Link to this callback

transaction(adapter_meta, options, function)

View Source
@callback 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 returned by the function or {:error, value} if the transaction was rolled back where value is the value given to rollback/1.