storage

package
v0.0.0-...-1f5092a Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSQLTransactionNoTrx        = errors.New("error on getting transaction context. no transaction available")
	ErrSQLTransactionFailedTrx    = errors.New("error on performing transactional request")
	ErrSQLTransactionFailedCommit = errors.New("failed to commit transaction")
)

transactional SQL error

Functions

This section is empty.

Types

type BaseStorage

type BaseStorage struct {
	Storage *connection.Store
}

func NewBaseStorage

func NewBaseStorage(store *connection.Store) *BaseStorage

func (*BaseStorage) SetTxToContext

func (r *BaseStorage) SetTxToContext(ctx context.Context, tx *sqlx.Tx) context.Context

set transaction to context

func (*BaseStorage) WithTransaction

func (r *BaseStorage) WithTransaction(ctx context.Context, fn TransactionFunc) error

wrapper function to handle transaction process

type SQLExec

type SQLExec interface {
	sqlx.Execer
	sqlx.ExecerContext
	NamedExec(query string, arg interface{}) (sql.Result, error)
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
}

type SQLQuery

type SQLQuery interface {
	sqlx.Queryer
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
}

type SQLQueryExec

type SQLQueryExec interface {
	SQLExec
	SQLQuery
	Rebind(query string) string
}

type TransactionFunc

type TransactionFunc func(ctx context.Context) error

Jump to

Keyboard shortcuts

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