stdscan package - github.com/stephenafamo/scan/stdscan - Go Packages
- func All[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) ([]T, error)
- func Cursor[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) (scan.ICursor[T], error)
- func Each[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], query string, args ...any) func(func(T, error) bool)
- func One[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) (T, error)
- type Queryer
This section is empty.
This section is empty.
All scans all rows from the query and returns a slice []T of all rows using a [StdQueryer] this is for use with *sql.DB, *sql.Tx or *sql.Conn or any similar implementations that return *sql.Rows
Cursor returns a cursor that works similar to *sql.Rows
Each returns a function that can be used to iterate over the rows of a query this function works with range-over-func so it is possible to do
for val, err := range scan.Each(ctx, exec, m, query, args...) {
if err != nil {
return err
}
// do something with val
}
One scans a single row from the query and maps it to T using a [StdQueryer] this is for use with *sql.DB, *sql.Tx or *sql.Conn or any similar implementations that return *sql.Rows
A Queryer that returns the concrete type *sql.Rows