orm

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Module is default connection to PostgreSQL
	Module = module.Module{
		{Constructor: NewDefaultConfig},
		{Constructor: NewConnection},
	}

	// ErrEmptyConfig when given empty options
	ErrEmptyConfig = errors.New("database empty config")
	// ErrEmptyLogger when logger not initialized
	ErrEmptyLogger = errors.New("database empty logger")
)

Functions

func NewConnection added in v0.5.0

func NewConnection(opts *Config, l *zap.Logger) (db *pg.DB, err error)

NewConnection returns database connection

Types

type Config

type Config = struct {
	Addr     string
	User     string
	Password string
	Database string
	Debug    bool
	PoolSize int
	Logger   *zap.SugaredLogger
}

Config alias

func NewDefaultConfig added in v0.5.0

func NewDefaultConfig(v *viper.Viper) (*Config, error)

NewDefaultConfig returns connection config

type Hook added in v0.9.0

type Hook struct {
	StartAt time.Time
	Before  func(*pg.QueryEvent)
	After   func(*pg.QueryEvent)
}

Hook is a simple implementation of pg.QueryHook

func (Hook) AfterQuery added in v0.9.0

func (h Hook) AfterQuery(e *pg.QueryEvent)

AfterQuery callback

func (*Hook) BeforeQuery added in v0.9.0

func (h *Hook) BeforeQuery(e *pg.QueryEvent)

BeforeQuery callback

Jump to

Keyboard shortcuts

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