Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) Create

func (db *DB) Create(ctx context.Context, stmts []string) 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

type Tx

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

Tx wraps a sql.Tx to offer: * apply some statement mutations before executing it * locking around concurrent executions of statements (since the underlying sql driver doesn't support concurrent statements on the same connection/transaction)

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) CurTime

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

func (*Tx) Exec

func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*Tx) Query

func (tx *Tx) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*Tx) QueryRow

func (tx *Tx) QueryRow(query string, args ...interface{}) *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"
)

Source Files