Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Placeholders ¶
Types ¶
type Database ¶
type Database interface { Begin() (Transaction, error) Close() error Driver() driver.Driver Exec(query string, args ...interface{}) (sql.Result, error) Ping() error Prepare(query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row SetMaxIdleConns(n int) SetMaxOpenConns(n int) }
We are using an interface to allow overwriting DB with a custom type. Useful for the integration tests where we don't want to open many transactions
var ( DB Database Driver = "postgres" )
type SQLer ¶
type SQLer interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
Could be a connection or a transaction
type Transaction ¶
type Transaction interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row Rollback() error Commit() error }
We are using this transaction to avoid commiting twice when reusing a transaction for the integration tests
Click to show internal directories.
Click to hide internal directories.