wrapper

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Querier
	BeginTxx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	Close() error
}

DB wraps sqlx.Tx and sqlx.DB https://github.com/jmoiron/sqlx/issues/344#issuecomment-318372779

func NewGddDB added in v1.0.6

func NewGddDB(db *sqlx.DB, options ...GddDBOption) DB

type GddDB

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

GddDB wraps sqlx.DB

func (*GddDB) BeginTxx

func (g *GddDB) BeginTxx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

BeginTxx begins a transaction

func (*GddDB) ExecContext added in v1.0.6

func (g *GddDB) ExecContext(ctx context.Context, query string, args ...interface{}) (ret sql.Result, err error)

func (*GddDB) GetContext added in v1.0.6

func (g *GddDB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

func (*GddDB) NamedExecContext added in v1.0.6

func (g *GddDB) NamedExecContext(ctx context.Context, query string, arg interface{}) (ret sql.Result, err error)

func (*GddDB) SelectContext added in v1.0.6

func (g *GddDB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

type GddDBOption added in v1.0.6

type GddDBOption func(*GddDB)

func WithCache added in v1.0.9

func WithCache(store *cache.Cache) GddDBOption

func WithLogger added in v1.0.6

func WithLogger(logger logger.SqlLogger) GddDBOption

func WithRedisKeyTTL added in v1.0.9

func WithRedisKeyTTL(ttl time.Duration) GddDBOption

type GddTx

type GddTx struct {
	*sqlx.Tx
	// contains filtered or unexported fields
}

GddTx wraps sqlx.Tx

func (*GddTx) ExecContext added in v1.0.6

func (g *GddTx) ExecContext(ctx context.Context, query string, args ...interface{}) (ret sql.Result, err error)

func (*GddTx) GetContext added in v1.0.6

func (g *GddTx) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

func (*GddTx) NamedExecContext added in v1.0.6

func (g *GddTx) NamedExecContext(ctx context.Context, query string, arg interface{}) (ret sql.Result, err error)

func (*GddTx) SelectContext added in v1.0.6

func (g *GddTx) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

type Querier

type Querier interface {
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Rebind(query string) string
	BindNamed(query string, arg interface{}) (string, []interface{}, error)
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

Querier common operations for sqlx.Tx and sqlx.DB

type Tx

type Tx interface {
	Querier
	Commit() error
	Rollback() error
}

Tx transaction

Jump to

Keyboard shortcuts

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