module
Marten::DB::Model::Connection
Direct including types
Defined in:
marten/db/model/connection.crInstance Method Summary
-
#transaction(using : Nil | String | Symbol = nil, &block)
Allows to run the underlying block in a database transaction.
-
#using : String | Nil
Returns the sticky database alias associated with the model instance, if any.
Instance Method Detail
Allows to run the underlying block in a database transaction.
A optional database alias can be specified in order to define the database connection to use in the context of
the transaction (otherwise the sticky alias of the instance or the model's write connection is used). If the
passed database alias doesn't correspond to any defined connections, a Marten::DB::Errors::UnknownConnection
error will be raised.
Returns the sticky database alias associated with the model instance, if any.
The sticky alias is set when a record is loaded from or persisted to a specific database via an explicit
#using selection. Subsequent operations on the instance reuse this alias unless another one is specified
explicitly.