This commit is contained in:
tobi 2021-09-30 11:16:23 +02:00 committed by GitHub
commit 231075f28d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)