pgxscan

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 7 Imported by: 0

README

pgxscan

GoDev Tests ReportCard License

Derived from https://github.com/vgarvardt/pgx-helpers.

A bunch of sqlx-esque pgx decoding functions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMapper = reflectx.NewMapperFunc("db", sqlx.NameMapper)

Functions

func Get

func Get(ctx context.Context, queryer Queryer, dest interface{}, query string, args ...interface{}) error

func ScanFlat

func ScanFlat(r pgx.Rows, dest interface{}) error

func ScanStruct

func ScanStruct(r pgx.Rows, dest interface{}) error

ScanStruct scans a pgx.Rows into destination struct passed by reference based on the "db" fields tags. This is workaround function for pgx.Rows with single row as pgx/v4 does not allow to get row metadata from pgx.Row - see https://github.com/jackc/pgx/issues/627 for details.

If there are no rows pgx.ErrNoRows is returned. If there are more than one row in the result - they are ignored. Function call closes rows, so caller may skip it.

func ScanStructs

func ScanStructs(r pgx.Rows, dest interface{}) error

ScanStructs scans a pgx.Rows into destination structs list passed by reference based on the "db" fields tags

func Select

func Select(ctx context.Context, queryer Queryer, dest interface{}, query string, args ...interface{}) error

func SelectFlat

func SelectFlat(ctx context.Context, queryer Queryer, dest interface{}, query string, args ...interface{}) error

Types

type Queryer

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

Jump to

Keyboard shortcuts

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