Documentation ¶
Overview ¶
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
Index ¶
- func Count(tx *sql.Tx, table string, where string, args ...interface{}) (int, error)
- func SelectConfig(tx *sql.Tx, table string, filters ...string) (map[string]string, error)
- func SelectIntegers(tx *sql.Tx, query string) ([]int, error)
- func SelectStrings(tx *sql.Tx, query string) ([]string, error)
- func Transaction(db *sql.DB, f func(*sql.Tx) error) error
- func UpdateConfig(tx *sql.Tx, table string, values map[string]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SelectConfig ¶
SelectConfig executes a query statement against a "config" table, which must have 'key' and 'value' columns. By default this query returns all keys, but additional WHERE filters can be specified.
Returns a map of key names to their associated values.
func SelectIntegers ¶
SelectIntegers executes a statement which must yield rows with a single integer column. It returns the list of column values.
func SelectStrings ¶
SelectStrings executes a statement which must yield rows with a single string column. It returns the list of column values.
func Transaction ¶
Transaction executes the given function within a database transaction.
Types ¶
This section is empty.