pgxscan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) ([]T, error)

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

func Collect

func Collect(ctx context.Context, exec Queryer, collector func(context.Context, map[string]int) any, sql string, args ...any) ([]any, error)

Collect multiple slices of values from a single query collector must be of the structure func(cols) func(*Values) (t1, t2, ..., error) The returned slice contains values like this {[]t1, []t2}

func Cursor

func Cursor[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) (scan.ICursor[T], error)

Cursor returns a cursor that works similar to *sql.Rows

func One

func One[T any](ctx context.Context, exec Queryer, m scan.Mapper[T], sql string, args ...any) (T, error)

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

Types

type Queryer

type Queryer interface {
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}

A Queryer that returns the concrete type [*sql.Rows]

Jump to

Keyboard shortcuts

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