Documentation ¶
Index ¶
- func Insert(db Execer, tableName string, vals H) (sql.Result, error)
- func InsertWithoutConflict(db Execer, tableName string, vals H) (sql.Result, error)
- func MustInsert(db Execer, tableName string, vals H) sql.Result
- func MustInsertWithoutConflict(db Execer, tableName string, vals H) sql.Result
- func MustQueryRows(db Querier, query string, args Args, foo func(RowScanner))
- func MustTransact(db *sql.DB, foo func(*sql.Tx))
- func QueryCol(db Querier, dest interface{}, query string, args ...interface{}) error
- func QueryCols(db Querier, dest interface{}, query string, args ...interface{}) error
- func QueryRows(db Querier, query string, args Args, foo func(RowScanner) error) error
- func QuoteString(s string) string
- func QuoteStrings(ss []string) (out []string)
- func SQLizeParams(vals H) (names, placeholders string, params []interface{})
- type Args
- type Execer
- type H
- type Querier
- type QueryRower
- type RowScanner
- type ScanValuer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertWithoutConflict ¶
InsertWithoutConflict inserts given values into the given database table with 'on conflict do nothing'
func MustInsert ¶
MustInsert inserts given values into the given database table and panics (in 'mustbe' way) if error
func MustInsertWithoutConflict ¶
MustInsertWithoutConflict inserts given values into the given database table with 'on conflict do nothing' and panics (in 'mustbe' way) if error
func MustQueryRows ¶
func MustQueryRows(db Querier, query string, args Args, foo func(RowScanner))
MustQueryRows performs Query and Scan's resulting Rows and panics (in 'mustbe' way) if error. It also expects mustbe-panic in foo.
func MustTransact ¶
MustTransact opens transaction and call foo with it. It rollback transaction if panic happens in foo and re-panic that panic.
func QueryCol ¶
QueryCol fetches a single column from the query result. dest must be a pointer to slice of column type.
func QueryCols ¶
QueryCols fetches all columns from the query result. dest must be a pointer to slice of structs with fields ordered and typed as columns.
func QuoteString ¶
QuoteString quotes string value according to PostgreSQL rules see https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
func QuoteStrings ¶
QuoteStrings quotes all strings in array
func SQLizeParams ¶
SQLizeParams converts vals to 1) string of names, 2) string of placeholders and 3) slice of params values
Types ¶
type QueryRower ¶
QueryRower is the interface for QueryRow method
type RowScanner ¶
type RowScanner interface {
Scan(dest ...interface{}) error
}
RowScanner is an interface with a sql.Row(s) Scan function
type ScanValuer ¶
ScanValuer interface combines sql.Scanner and driver.Valuer
func JSONVal ¶
func JSONVal(v interface{}) ScanValuer
JSONVal returns an object implementing ScanValuer interfaces to read/write JSON(b) values from/to DB. 'v' must be pointer for Scan use.