#include </data/code/userver/mysql/include/userver/storages/mysql/transaction.hpp>
RAII transaction wrapper, auto-ROLLBACKs on destruction if no prior Commit
/Rollback
call was made.
This type can't be constructed in user code and is always retrieved from storages::mysql::Cluster
Definition at line 29 of file transaction.hpp.
Public Member Functions | |
Transaction (infra::ConnectionPtr &&connection, engine::Deadline deadline) | |
Transaction (const Transaction &other)=delete | |
Transaction (Transaction &&other) noexcept | |
template<typename... Args> | |
StatementResultSet | Execute (const Query &query, const Args &... args) const |
Executes a statement with default deadline. Fills placeholders of the statement with args..., Args are expected to be of supported types. See userver_mysql_types for better understanding of Args requirements. | |
template<typename T > | |
StatementResultSet | ExecuteDecompose (const Query &query, const T &row) const |
Executes a statement with default deadline. | |
template<typename Container > | |
StatementResultSet | ExecuteBulk (const Query &query, const Container ¶ms) const |
Executes a statement with default deadline. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See userver_mysql_types for better understanding of Container::value_type requirements. | |
template<typename MapTo , typename Container > | |
StatementResultSet | ExecuteBulkMapped (const Query &query, const Container ¶ms) const |
Executes a statement with default deadline, on the flight remapping from Container::value_type to MapTo . Container is expected to be a std::Container of whatever type pleases you, MapTo is expected to be an aggregate of supported types. See userver_mysql_types for better understanding of MapTo requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>) in namespace of MapTo or storages::mysql::convert. | |
void | Commit () |
Commit the transaction. | |
void | Rollback () |
Rollback the transaction. | |
StatementResultSet storages::mysql::Transaction::Execute | ( | const Query & | query, |
const Args &... | args ) const |
Executes a statement with default deadline. Fills placeholders of the statement with args..., Args
are expected to be of supported types. See userver_mysql_types for better understanding of Args
requirements.
UINVARIANTs on params count mismatch doesn't validate types.
Definition at line 109 of file transaction.hpp.
StatementResultSet storages::mysql::Transaction::ExecuteBulk | ( | const Query & | query, |
const Container & | params ) const |
Executes a statement with default deadline. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See userver_mysql_types for better understanding of Container::value_type
requirements.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 123 of file transaction.hpp.
StatementResultSet storages::mysql::Transaction::ExecuteBulkMapped | ( | const Query & | query, |
const Container & | params ) const |
Executes a statement with default deadline, on the flight remapping from Container::value_type
to MapTo
. Container
is expected to be a std::Container of whatever type pleases you, MapTo
is expected to be an aggregate of supported types. See userver_mysql_types for better understanding of MapTo
requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>)
in namespace of MapTo
or storages::mysql::convert.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 132 of file transaction.hpp.
StatementResultSet storages::mysql::Transaction::ExecuteDecompose | ( | const Query & | query, |
const T & | row ) const |
Executes a statement with default deadline.
Basically an alias for Execute(host_type, query, AsArgs<T>(row)), where AsArgs is an imaginary function which passes fields of T as variadic params. Handy for one-liner inserts. See userver_mysql_types for better understanding of T
requirements.
UINVARIANTs on params count mismatch, doesn't validate types.
Definition at line 116 of file transaction.hpp.