sql

package
Version: v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// DriverName ... FIXME
	DriverName() string

	// DSN ... FIXME
	DSN() string
}

Config ... FIXME

type DB

type DB interface {
	Begin(ctx context.Context, opts *TxOptions) (Tx, error)

	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Prepare(ctx context.Context, query string) (Stmt, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row

	Close() error
	Ping(ctx context.Context) error
}

func Open

func Open(config Config, opts ...Option) (DB, error)

type Logger

type Logger = log.Logger

What I would like:

type Logger[L any] interface {
	WithField(key string, value interface{}) L

	Infoln(args ...interface{})
	Infof(format string, args ...interface{})
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets options such as instumenting the DB with logging.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger returns an Option that instruments the DB with logging.

type Result

type Result = sql.Result

type Row

type Row = sql.Row

type Rows

type Rows = sql.Rows

type Stmt

type Stmt interface {
	Exec(ctx context.Context, args ...interface{}) (Result, error)
	Query(ctx context.Context, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, args ...interface{}) *Row

	Close() error
}

type Tx

type Tx interface {
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Prepare(ctx context.Context, query string) (Stmt, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row

	Commit() error
	Rollback() error

	Stmt(ctx context.Context, stmt Stmt) Stmt
}

type TxOptions

type TxOptions = sql.TxOptions

Directories

Path Synopsis
Package mocksql is a generated GoMock package.
Package mocksql is a generated GoMock package.

Jump to

Keyboard shortcuts

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