module
Marten::DB::Model::Connection::ClassMethods
Defined in:
marten/db/model/connection.crInstance Method Summary
-
#connection(*, write : Bool = false)
Returns the database connection to use for the considered model.
-
#transaction(using : Nil | String | Symbol = nil, &)
Allows to run the underlying block in a database transaction.
Instance Method Detail
Returns the database connection to use for the considered model.
By default the connection is resolved by consulting the configured database routers. The optional write
argument can be set to true in order to resolve the connection for write operations instead of reads.
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 write connection for the model is used). If the passed database alias
doesn't correspond to any defined connections, a Marten::DB::Errors::UnknownConnection error will be
raised.