Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
type Executable interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}
Executable interface for sql ExecContext method
type Queryable ¶
type Queryable interface {
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
Queryable interface for sql QueryContext method
type ScanContext ¶
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 ¶
func NewScanContext(rows *sql.Rows) (*ScanContext, error)
NewScanContext creates new ScanContext from rows