Documentation ¶
Index ¶
- func Close()
- func Do(ctx context.Context, sql string, args ...any) error
- func Init(config *koanf.Koanf) error
- func Multiple[T any](ctx context.Context, sql string, args ...any) ([]T, error)
- func RowToAddrOfStructByName[T any](row pgx.CollectableRow) (*T, error)
- func RowToStructByName[T any](row pgx.CollectableRow) (T, error)
- func Single[T any](ctx context.Context, sql string, args ...any) (*T, error)
- type Postgres
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Multiple ¶
Runs a query which returns multiple rows and collects them in a slice of type []T using pgx.RowToStructByName. If no records were returned by the query, an empty slice is returned, along with the pgx error.
func RowToAddrOfStructByName ¶
RowToAddrOfStructByPos returns the address of a T scanned from row. T must be a struct. T must have the same number of named public fields as row has fields. The row and T fields will by matched by name. The match is case-insensitive. The database column name can be overridden with a "db" struct tag. If the "db" struct tag is "-" then the field will be ignored. Handles embedded structs, if they specify "embedded" in the "db" tag.
func RowToStructByName ¶
RowToStructByName returns a T scanned from row. T must be a struct. T must have the same number of named public fields as row has fields. The row and T fields will by matched by name. The match is case-insensitive. The database column name can be overridden with a "db" struct tag. If the "db" struct tag is "-" then the field will be ignored. Handles embedded structs, if they specify "embedded" in the "db" tag.