sqlapi

package
v0.0.0-...-97057f0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BindVarChar = '?'
	TimeLayout  = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Transactional
	ReaderWriter
}

func Log

func Log(db DB, f LogFunc) DB

type LogEntry

type LogEntry struct {
	Query    func() string
	Rows     int64
	Err      error
	Time     time.Time
	Duration time.Duration
}

type LogFunc

type LogFunc func(context.Context, LogEntry)

type NoRows

type NoRows struct {
	Err error
}

func (NoRows) Error

func (rows NoRows) Error() error

func (NoRows) Scan

func (rows NoRows) Scan(output interface{}) error

type Query

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

func NewQuery

func NewQuery(text string) Query

func (Query) Args

func (q Query) Args() []interface{}

func (Query) FlatArgs

func (q Query) FlatArgs() Query

func (Query) Inject

func (q Query) Inject(values ...interface{}) Query

func (Query) String

func (q Query) String() string

func (Query) Text

func (q Query) Text() string

func (Query) WithArgs

func (q Query) WithArgs(args ...interface{}) Query

type Reader

type Reader interface {
	Read(ctx context.Context, q Query) Rows
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

type Result

type Result struct {
	LastInsertId int64
	RowsAffected int64
	Error        error
}

type Rows

type Rows interface {
	Error() error
	Scan(output interface{}) error
}

type Transactional

type Transactional interface {
	InTransaction(perform func(ReaderWriter) error) error
}

type Writer

type Writer interface {
	Write(ctx context.Context, q Query) Result
}

Jump to

Keyboard shortcuts

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