Documentation ¶
Index ¶
- func DbTxDone[A DbTx](val A)
- func NextVal[Val any, Src ColumnerScanner](src Src) Val
- func RowsCols[A Columner](val A) []string
- func RowsDone[A io.Closer](val A)
- func RowsErr[A Errer](val A) error
- func RowsOk[A Errer](val A)
- func RowsScan[A Scanner](src A, buf []any)
- func ScanAny[Src Rows](src Src, out any)
- func ScanVal[Val any, Src Rows](src Src) Val
- func ScanVals[Val any, Src Rows](src Src) (out []Val)
- type Arr
- func (self Arr[A]) Append(buf []byte) []byte
- func (self Arr[A]) AppendInner(buf []byte) []byte
- func (self *Arr[A]) Clear()
- func (self Arr[A]) Get() any
- func (self Arr[A]) IsNull() bool
- func (self *Arr[A]) Parse(src string) (err error)
- func (self *Arr[A]) Scan(src any) error
- func (self Arr[A]) String() string
- func (self Arr[A]) Value() (driver.Value, error)
- type Columner
- type ColumnerScanner
- type Db
- type DbConn
- type DbTx
- type DbTxer
- type Errer
- type Nexter
- type Rows
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DbTxDone ¶
func DbTxDone[A DbTx](val A)
Must be deferred. Commit if there was no panic, rollback if there was a panic. Usage:
defer DbTxDone(conn)
func NextVal ¶
func NextVal[Val any, Src ColumnerScanner](src Src) Val
Types ¶
type Arr ¶
type Arr[A any] []A
Short for "array". A slice type that supports SQL array encoding and decoding, using the `{}` format. Examples:
Arr[int]{10, 20} <-> '{10,20}' Arr[Arr[int]]{{10, 20}, {30, 40}} <-> '{{10,20},{30,40}}'
func ToArr ¶
Shortcut for casting into `Arr`. Workaround for lack of type inference in type literals and casts.
func (Arr[A]) Append ¶
Implement `Appender`, appending the array's SQL encoding to the buffer. If the slice is nil, appends nothing.
func (Arr[A]) AppendInner ¶
Same as `.Append` but without the enclosing `{}`.
func (Arr[A]) Get ¶
Implement `Getter` for compatibility with 3rd party libraries such as `pgx`. If the slice is nil, returns nil. Otherwise returns the SQL-encoded string representation.
type ColumnerScanner ¶
type DbConn ¶
type DbConn interface { QueryContext(context.Context, string, ...any) (*sql.Rows, error) ExecContext(context.Context, string, ...any) (sql.Result, error) }
Implemented by stdlib types such as `sql.Conn` and `sql.Tx`.