dbutils

package
v0.0.0-...-8c2001a Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxNotFound = errors.New("Tx: not found")
)

Functions

func Execute

func Execute(driver *sql.DB, qstr string) error

func GetScan

func GetScan(rows *sql.Rows) (map[string]any, error)

func SelectScan

func SelectScan(rows *sql.Rows) ([]map[string]any, error)

func Table

func Table(sess db.Session, name string) db.Collection

Types

type Time

type Time struct {
	Inner time.Time
}

func (Time) MarshalJSON

func (mt Time) MarshalJSON() ([]byte, error)

func (*Time) Scan

func (mt *Time) Scan(val any) error

func (*Time) UnmarshalJSON

func (mt *Time) UnmarshalJSON(data []byte) error

func (Time) Value

func (mt Time) Value() (driver.Value, error)

type Tx

type Tx interface {
	db.Session
	Commit() error
	Rollback() error
}

bcz sqlbuilder.Tx is internal/private package cannot import it

type TxManager

type TxManager struct {
	// contains filtered or unexported fields
}

func NewTxMgr

func NewTxMgr(fn func(sqlTx *sql.Tx) (Tx, error)) TxManager

func (*TxManager) CommitTx

func (d *TxManager) CommitTx(txid uint32) error

func (*TxManager) NewTxn

func (d *TxManager) NewTxn(sess db.Session, timeout int) (uint32, error)

func (*TxManager) RollbackTx

func (d *TxManager) RollbackTx(txid uint32) error

func (*TxManager) TxOr

func (d *TxManager) TxOr(txid uint32, dbsess db.Session, fn func(sess db.Session) error) error

TxOr runs in txn or directly db connection

type TxnWrapped

type TxnWrapped struct {
	// contains filtered or unexported fields
}

func (*TxnWrapped) Close

func (t *TxnWrapped) Close()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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