Documentation
¶
Index ¶
- Constants
- Variables
- func DoMigrate(m *migrate.Migrate) (err error)
- func NewDB(cfg *conf.Config) (*sql.DB, error)
- func NewMigrate(db *sql.DB) *migrate.Migrate
- func Open(dataSource string) (*sql.DB, error)
- func TestContext(t testing.TB) context.Context
- func WithTransaction(ctx context.Context, db *sql.DB, fn TxFn) (err error)
- type Transaction
- type TxFn
Constants ¶
View Source
const DefaultMaxOpenConnections = 30
DefaultMaxOpenConnections the default value for max open connections in the PostgreSQL connection pool.
Variables ¶
View Source
var (
Global *sql.DB
)
Functions ¶
Types ¶
type Transaction ¶
type Transaction interface { Exec(query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Transaction is an interface that models the standard transaction in `database/sql`.
To ensure `TxFn` funcs cannot commit or rollback a transaction (which is handled by `WithTransaction`), those methods are not included here.
type TxFn ¶
type TxFn func(Transaction) error
TxFn is a function that will be called with an initialised `Transaction` object that can be used for executing statements and queries against a database.
Click to show internal directories.
Click to hide internal directories.