postgres

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBMigrationsInitializedErrPrefix = "ERROR #42P07" // safe to ignore, error when gopg_migrations already exists
	DBStatementCancelledErrPrefix    = "ERROR #57014"
)

Variables

This section is empty.

Functions

func DBMigrationsAlreadyInit

func DBMigrationsAlreadyInit(err error) bool

func DBStatementCancelledByUser

func DBStatementCancelledByUser(err error) bool

func WithContextTimeout

func WithContextTimeout(ctx context.Context, f func(ctx context.Context))

WithContextTimeout executes statements with a default timeout

func WithContextTimeoutValue

func WithContextTimeoutValue(ctx context.Context, timeout time.Duration, f func(ctx context.Context))

WithContextTimeoutValue executes an inner routine while passing a ctx that supports custom timeout and query cancellation to the postgres server.

Types

type TGPGDB

type TGPGDB struct {
	*pg.DB
}

func CreateTGPGDB

func CreateTGPGDB(url string) *TGPGDB

func NewTGPGDB

func NewTGPGDB(db *pg.DB) *TGPGDB

func (*TGPGDB) ExecContext

func (db *TGPGDB) ExecContext(ctx context.Context, query interface{}, params ...interface{}) (pg.Result, error)

func (*TGPGDB) Migrate

func (db *TGPGDB) Migrate() error

Migrate check and migrate to lastest db version.

func (*TGPGDB) ModelContext

func (db *TGPGDB) ModelContext(ctx context.Context, models ...interface{}) *orm.Query

func (*TGPGDB) Ping

func (db *TGPGDB) Ping() error

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) error) error

RunInTransactionContext wraps around underlying go-pg's rollback-supported transaction execution with our custom context so it can be easily passed down.

Jump to

Keyboard shortcuts

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