Documentation ¶
Index ¶
- Constants
- func DBMigrationsAlreadyInit(err error) bool
- func DBStatementCancelledByUser(err error) bool
- func WithContextTimeout(ctx context.Context, f func(ctx context.Context))
- func WithContextTimeoutValue(ctx context.Context, timeout time.Duration, f func(ctx context.Context))
- type TGPGDB
- func (db *TGPGDB) ExecContext(ctx context.Context, query interface{}, params ...interface{}) (pg.Result, error)
- func (db *TGPGDB) Migrate() error
- func (db *TGPGDB) ModelContext(ctx context.Context, models ...interface{}) *orm.Query
- func (db *TGPGDB) Ping() error
- func (db *TGPGDB) RunInTransactionContext(ctx context.Context, txFunc func(context.Context, *TGPGDB) error) error
- func (db *TGPGDB) WithTimeout(timeout time.Duration) *TGPGDB
- type TGPGDBOptions
Constants ¶
View Source
const ( DBMigrationsConcurrentInitErrPrefix = "ERROR #23505" // safe to ignore, error when gopg_migrations already exists DBStatementCancelledErrPrefix = "ERROR #57014" )
Variables ¶
This section is empty.
Functions ¶
func DBMigrationsAlreadyInit ¶
func WithContextTimeout ¶
WithContextTimeout executes statements with a default timeout
Types ¶
type TGPGDB ¶
type TGPGDB struct {
*pg.DB
}
func CreateTGPGDB ¶
func CreateTGPGDBWithOptions ¶
func CreateTGPGDBWithOptions(dbOpts *TGPGDBOptions) *TGPGDB
func (*TGPGDB) ExecContext ¶
func (*TGPGDB) ModelContext ¶
func (*TGPGDB) Ping ¶
Ping simulates a "blank query" behavior similar to lib/pq's to check if the db connection is alive.
func (*TGPGDB) RunInTransactionContext ¶
func (db *TGPGDB) RunInTransactionContext(ctx context.Context, txFunc func(context.Context, *TGPGDB) error) error
RunInTransactionContext wraps around underlying go-pg's rollback-supported transaction execution with our custom context so it can be easily passed down.
type TGPGDBOptions ¶
Click to show internal directories.
Click to hide internal directories.