database

package
v0.0.0-...-cf4d00b Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosePool

func ClosePool() error

func InitPool

func InitPool() error

Types

type Conn

type Conn interface {
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Begin() (TxConn, error)
	Transaction(func(TxConn) error) error
	Close() error
}

func Pool

func Pool() Conn

type ConnPool

type ConnPool struct {
	*sqlx.DB
}

func New

func New(driver string, conn string) (*ConnPool, error)

func (ConnPool) Begin

func (c ConnPool) Begin() (TxConn, error)

func (ConnPool) Transaction

func (c ConnPool) Transaction(f func(TxConn) error) error

type TxConn

type TxConn interface {
	Conn
	ExecContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	Commit() error
	Rollback() error
}

type TxDatabase

type TxDatabase struct {
	ConnPool
	*sqlx.Tx
}

func (TxDatabase) ExecContext

func (db TxDatabase) ExecContext(ctx context.Context, query string, args ...interface{}) *sql.Row

Jump to

Keyboard shortcuts

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