summaryrefslogtreecommitdiff
path: root/lib/dbConn.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dbConn.h')
-rw-r--r--lib/dbConn.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/dbConn.h b/lib/dbConn.h
index 3f14dcb..ffdd2e0 100644
--- a/lib/dbConn.h
+++ b/lib/dbConn.h
@@ -24,6 +24,28 @@ namespace MyGrate {
virtual void query(const char * const, const std::initializer_list<DbValue> &) = 0;
virtual DbPrepStmtPtr prepare(const char * const, std::size_t nParams) = 0;
+
+ virtual void beginTx() = 0;
+ virtual void commitTx() = 0;
+ virtual void rollbackTx() = 0;
+ };
+
+ class Tx {
+ public:
+ explicit Tx(DbConn *);
+ Tx(const Tx &) = delete;
+ Tx(Tx &&) = delete;
+ ~Tx();
+
+ template<typename C>
+ auto
+ operator()(C && callback)
+ {
+ return callback();
+ }
+
+ private:
+ DbConn * conn;
};
}