Documentation
¶
Overview ¶
Package rowmap maps database/sql rows onto structs, maps and scalars.
Index ¶
- func First(rows *sql.Rows, dest any) error
- func Slice(rows *sql.Rows, dest any) error
- func StructType(t reflect.Type) (reflect.Type, error)
- func StructValue(v reflect.Value) (reflect.Value, error)
- func Target(dst reflect.Value) (any, func())
- func ToRows(t reflect.Type, vals []reflect.Value) ([]map[string]any, error)
- func ValueOfColumn(elem reflect.Value, column string) (any, error)
- type Field
- type Mapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func First ¶
First scans the first row into dest (*struct, *map[string]any or *scalar); it returns sql.ErrNoRows when there are no rows. The remaining rows are ignored.
func StructType ¶
StructType dereferences pointer types and requires a struct.
func StructValue ¶
StructValue dereferences pointers and interfaces and requires the result to be a struct.
func Target ¶
Target returns what to hand rows.Scan for dst, plus an optional step to run afterwards. Plain value types are scanned through a **T so that NULL leaves the zero value rather than failing.
Types ¶
type Field ¶
Field is one writable column of a struct.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper scans successive rows into values of one element type. It keeps scratch state between rows, so one Mapper must not be used from several goroutines.