Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(cfg *config.CommonConfigFlags) error
Connect connects to the database mentioned in the config variable.
func DBInstance ¶
func DBInstance() (*pg.DB, error)
DBInstance returns a reference to the database connection
func Migrate ¶
func Migrate(cfg *config.CommonConfigFlags) error
Migrate database to the latest version.
Types ¶
type Context ¶
Context is an interface type representing the context in which queries run, currently relating to the existence or non-existence of a database transaction Call `.NoTx()` or `.NewTx()` to acquire a Context
type DB ¶
type DB interface { Model(model ...interface{}) *orm.Query Select(model interface{}) error Insert(model ...interface{}) error Update(model interface{}) error Delete(model interface{}) error QueryOne(model, query interface{}, params ...interface{}) (orm.Result, error) }
DB is an interface type implemented both by pg.DB and pg.Tx. We use DB to execute db operations with or without transaction context.
type TxContext ¶
type TxContext struct {
// contains filtered or unexported fields
}
TxContext represents a database context with an attached database transaction
func (*TxContext) RollbackUnlessCommitted ¶
RollbackUnlessCommitted rolls-back the transaction attached to this TxContext if the transaction was not committed.