db

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](stmt *sqlx.Stmt, args ...any) (dest *T, err error)

Get[T] using the prepared statement. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func GetContext

func GetContext[T any](ctx context.Context, stmt *sqlx.Stmt, args ...any) (dest *T, err error)

GetContext[T] using the prepared statement. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func InGet

func InGet[T any](q sqlx.Queryable, query string, args ...any) (dest *T, err error)

InGet[T] for in scene does a QueryRow using the provided Queryer, and scans the resulting row to dest. If dest is scannable, the result must only have one column. Otherwise, StructScan is used. Get will return sql.ErrNoRows like row.Scan would. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func InSelect

func InSelect[T any](q sqlx.Queryable, query string, args ...any) (dest *T, err error)

InSelect[T] for in scene executes a query using the provided Queryer, and StructScans each row into dest, which must be a slice. If the slice elements are scannable, then the result set must have only one column. Otherwise, StructScan is used. The *sql.Rows are closed automatically. Any placeholder parameters are replaced with supplied args.

func NamedGet

func NamedGet[T any](stmt *sqlx.NamedStmt, arg any) (dest *T, err error)

NamedGet[T] using this NamedStmt Any named placeholder parameters are replaced with fields from arg.

func NamedGetContext

func NamedGetContext[T any](ctx context.Context, stmt *sqlx.NamedStmt, arg any) (dest *T, err error)

NamedGetContext using this NamedStmt Any named placeholder parameters are replaced with fields from arg.

func NamedSelect

func NamedSelect[T any](stmt *sqlx.NamedStmt, arg any) (dest *T, err error)

NamedSelect using this NamedStmt Any named placeholder parameters are replaced with fields from arg.

func NamedSelectContext

func NamedSelectContext[T any](ctx context.Context, stmt *sqlx.NamedStmt, arg any) (dest *T, err error)

NamedSelectContext using this NamedStmt Any named placeholder parameters are replaced with fields from arg.

func Select

func Select[T any](stmt *sqlx.Stmt, args ...any) (dest *T, err error)

Select[T] using the prepared statement. Any placeholder parameters are replaced with supplied args.

func SelectContext

func SelectContext[T any](ctx context.Context, stmt *sqlx.Stmt, args ...any) (dest *T, err error)

SelectContext[T] using the prepared statement. Any placeholder parameters are replaced with supplied args.

func StructScan

func StructScan[T any](rows *sqlx.Rows) (dest *T, err error)

StructScan[T] all rows from an sql.Rows or an sqlx.Rows into the dest slice. StructScan[T] will scan in the entire rows result, so if you do not want to allocate structs for the entire result, use Queryx and see sqlx.Rows.StructScan. If rows is sqlx.Rows, it will use its mapper, otherwise it will use the default.

Types

This section is empty.

Jump to

Keyboard shortcuts

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