pgxscan

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
}

Jump to

Keyboard shortcuts

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