wrapper

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 9 Imported by: 0

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) (GddTx, error)
	Close() error
}

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

type GddDB

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

GddDB wraps sqlx.DB

func NewGddDB

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

func (GddDB) BeginTxx

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

BeginTxx begins a transaction

func (GddDB) ExecContext

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

func (GddDB) GetContext

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

func (GddDB) NamedExecContext

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

func (GddDB) SelectContext

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

type GddDBOption

type GddDBOption func(*GddDB)

func WithCache

func WithCache(store *cache.Cache) GddDBOption

func WithLogger

func WithLogger(logger logger.SqlLogger) GddDBOption

func WithRedisKeyTTL

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

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

func (GddTx) GetContext

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

func (GddTx) NamedExecContext

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

func (GddTx) SelectContext

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