v0.8.0 Latest Latest

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type DB

type DB struct {
	// contains filtered or unexported fields

DB wraps a sql.DB to add special behaviors based on the db type

func NewDB

func NewDB(dbType Type, dbConnString string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Conn

func (db *DB) Conn(ctx context.Context) (*sql.Conn, error)

func (*DB) Do

func (db *DB) Do(ctx context.Context, f func(tx *Tx) error) error

func (*DB) NewTx

func (db *DB) NewTx(ctx context.Context) (*Tx, error)

func (*DB) NewUnstartedTx

func (db *DB) NewUnstartedTx() *Tx

func (*DB) Type

func (db *DB) Type() Type

type Tx

type Tx struct {
	// contains filtered or unexported fields

Tx wraps a sql.Tx to: * Setup the transaction (set isolation levels etc...) * Apply some statement mutations before executing it

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) CurTime

func (tx *Tx) CurTime() (time.Time, error)

func (*Tx) DBType

func (tx *Tx) DBType() Type

func (*Tx) Exec

func (tx *Tx) Exec(query string, args ...any) (sql.Result, error)

func (*Tx) ID

func (tx *Tx) ID() string

func (*Tx) Query

func (tx *Tx) Query(query string, args ...any) (*sql.Rows, error)

func (*Tx) QueryRow

func (tx *Tx) QueryRow(query string, args ...any) *sql.Row

func (*Tx) Rollback

func (tx *Tx) Rollback() error

func (*Tx) Start

func (tx *Tx) Start(ctx context.Context) error

type Type

type Type string
const (
	Sqlite3  Type = "sqlite3"
	Postgres Type = "postgres"

Jump to

Keyboard shortcuts

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