constructsql

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertRowsAffected

func AssertRowsAffected(operation string, expectedRows int) func(sql.Result, error) error

AssertRowsAffected checks if the given result affected exactly the expected number of rows.

func CollectRows

func CollectRows[T any](rows Rows, queryErr error) (result []T, err error)

CollectRows collects all rows to the given target type from a ExecutiveQueryBuilder.Query result.

func IterateRows added in v2.2.0

func IterateRows[T any](rows Rows, err error) iter.Seq2[T, error]

IterateRows returns an iterator over the rows of a database query and scans them to T. If an error occurred initially, while scanning or closing, it returns a single-use iterator with the error. It returns a single-use iterator.

func ScanRow

func ScanRow[T any](row RowScanner, err error) (T, error)

ScanRow scans a single row to the given target type from a ExecutiveQueryBuilder.QueryRow result. It expects a single JSON column to be selected and unmarshals to the given struct type.

Types

type RowScanner

type RowScanner interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	RowScanner
	Next() bool
	Close() error
	Err() error
}

Jump to

Keyboard shortcuts

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