postgres

package
Version: v0.0.0-...-5f382f4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(cfg config.Postgres, lgr DBLogger) error

Load - loads pg instance.

Types

type DBLogger

type DBLogger interface {
	Debug(args ...interface{})
	Debugf(fmt string, args ...interface{})
}

type DBModel

type DBModel interface {
	Model(model ...interface{}) *orm.Query
	Exec(query interface{}, params ...interface{}) (pg.Result, error)
}

type DBQuery

type DBQuery struct {
	DBModel
	// contains filtered or unexported fields
}

func (*DBQuery) Commit

func (q *DBQuery) Commit() error

Commit makes commit on transaction or do nothing.

func (*DBQuery) Rollback

func (q *DBQuery) Rollback() error

Rollback rollbacks query if it was transaction or returns error.

func (*DBQuery) RollbackTx

func (q *DBQuery) RollbackTx(info string)

RollbackTx is the wrapper for graceful transaction rollback.

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

Postgres pg connection.

func GetDB

func GetDB() *Postgres

GetDB returns pg DB instance.

func (Postgres) NewTXContext

func (p Postgres) NewTXContext(ctx context.Context) (*DBQuery, error)

NewTXContext returns DBQuery instance with new transaction DBQuery.Commit() must be called to run transaction.

func (*Postgres) Ping

func (p *Postgres) Ping() (err error)

Ping checks db connection.

func (Postgres) QueryContext

func (p Postgres) QueryContext(ctx context.Context) *DBQuery

QueryContext returns DBQuery instance of current db pool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL