qrm

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 11 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRows = errors.New("qrm: no rows in result set")

ErrNoRows is returned by Query when query result set is empty

Functions

func Query

func Query(ctx context.Context, db Queryable, query string, args []interface{}, destPtr interface{}) (rowsProcessed int64, err error)

Query executes Query Result Mapping (QRM) of `query` with list of parametrized arguments `arg` over database connection `db` using context `ctx` into destination `destPtr`. Destination can be either pointer to struct or pointer to slice of structs. If destination is pointer to struct and query result set is empty, method returns qrm.ErrNoRows.

func ScanOneRowToDest added in v2.5.0

func ScanOneRowToDest(scanContext *ScanContext, rows *sql.Rows, destPtr interface{}) error

ScanOneRowToDest will scan one row into struct destination

Types

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

DB is common database interface used by query result mapping Both *sql.DB and *sql.Tx implements DB interface

type Executable added in v2.8.0

type Executable interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

Executable interface for sql ExecContext method

type Queryable added in v2.8.0

type Queryable interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

Queryable interface for sql QueryContext method

type ScanContext added in v2.7.1

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

ScanContext contains information about current row processed, mapping from the row to the destination types and type grouping information.

func NewScanContext added in v2.7.1

func NewScanContext(rows *sql.Rows) (*ScanContext, error)

NewScanContext creates new ScanContext from rows

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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