Browse Source

Add Begin

Volodymyr Tkach 2 years ago
parent
commit
deb26f74f6
2 changed files with 5 additions and 0 deletions
  1. 1 0
      gosql/common/common.go
  2. 4 0
      gosql/common/dbmethods.go

+ 1 - 0
gosql/common/common.go

@@ -15,6 +15,7 @@ import (
 )
 )
 
 
 type Engine interface {
 type Engine interface {
+	Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
 	Close() error
 	Close() error
 	Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
 	Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
 	Ping(context.Context) error
 	Ping(context.Context) error

+ 4 - 0
gosql/common/dbmethods.go

@@ -21,6 +21,10 @@ func (db *DBMethods) fixQuery(query string) string {
 	return query
 	return query
 }
 }
 
 
+func (db *DBMethods) Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) {
+	return db.DB.BeginTx(ctx, opts)
+}
+
 func (db *DBMethods) Close() error {
 func (db *DBMethods) Close() error {
 	return db.DB.Close()
 	return db.DB.Close()
 }
 }