query

package
v0.0.0-...-f59c3e7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package query implements helpers around database/sql to execute various kinds of very common SQL queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(tx *sql.Tx, table string, where string, args ...interface{}) (int, error)

Count returns the number of rows in the given table.

func SelectConfig

func SelectConfig(tx *sql.Tx, table string, filters ...string) (map[string]string, error)

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

func SelectIntegers(tx *sql.Tx, query string) ([]int, error)

SelectIntegers executes a statement which must yield rows with a single integer column. It returns the list of column values.

func SelectStrings

func SelectStrings(tx *sql.Tx, query string) ([]string, error)

SelectStrings executes a statement which must yield rows with a single string column. It returns the list of column values.

func Transaction

func Transaction(db *sql.DB, f func(*sql.Tx) error) error

Transaction executes the given function within a database transaction.

func UpdateConfig

func UpdateConfig(tx *sql.Tx, table string, values map[string]string) error

UpdateConfig updates the given keys in the given table. Config keys set to empty values will be deleted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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