dbconnect

package
v0.0.0-...-ed2ac0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownDBType = errors.New("unknown database type")
	ErrUnknownTable  = errors.New("unknown table")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(options config.Config) (*DB, error)

func NewDBMock

func NewDBMock(options config.Config) (*DB, sqlmock.Sqlmock, error)

func (*DB) CheckTableExists

func (db *DB) CheckTableExists(table string) (bool, error)

func (*DB) NewBuilder

func (db *DB) NewBuilder() squirrel.StatementBuilderType

func (*DB) Transaction

func (db *DB) Transaction(ctx context.Context, transaction TransactionFunc, options *sql.TxOptions) error

type DBContextKey

type DBContextKey string
const (
	CtxKeyTable DBContextKey = "tableName"
)

type TransactionFunc

type TransactionFunc func(tx *sql.Tx) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址