This commit is contained in:
tobi
2021-09-30 11:16:23 +02:00
committed by GitHub
parent 36a09dd0df
commit 231075f28d
7 changed files with 21 additions and 40 deletions

View File

@@ -45,6 +45,8 @@ import (
"github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/dialect/sqlitedialect"
"github.com/uptrace/bun/migrate"
// blank import for the sqlite driver for bun
_ "modernc.org/sqlite"
)

View File

@@ -10,7 +10,7 @@ import (
"github.com/uptrace/bun/dialect"
)
// dbConn wrapps a bun.DB conn to provide SQL-type specific additional functionality
// DBConn wrapps a bun.DB conn to provide SQL-type specific additional functionality
type DBConn struct {
// TODO: move *Config here, no need to be in each struct type
@@ -37,6 +37,7 @@ func WrapDBConn(dbConn *bun.DB, log *logrus.Logger) *DBConn {
}
}
// RunInTx wraps execution of the supplied transaction function.
func (conn *DBConn) RunInTx(ctx context.Context, fn func(bun.Tx) error) db.Error {
// Acquire a new transaction
tx, err := conn.BeginTx(ctx, nil)