database

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: GPL-3.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SchemaParam = "db_schema"
)

Variables

View Source
var (
	ErrNotConnected = errors.New("db: not connected")
)

Functions

func Close

func Close()

func InitDb

func InitDb(config structure.DBConfiguration)

func InitDbV2

func InitDbV2(config structure.DBConfiguration, callback func(db *DBManager))

func InitDbV2WithSchema

func InitDbV2WithSchema(config structure.DBConfiguration, schema string, callback func(db *DBManager))

func InitDbWithCurrentSchema

func InitDbWithCurrentSchema(config structure.DBConfiguration)

func InitDbWithSchema

func InitDbWithSchema(config structure.DBConfiguration, schema string)

func NewDbConnection

func NewDbConnection(config structure.DBConfiguration) (*pg.DB, error)

func NewLogQueryHook added in v1.3.0

func NewLogQueryHook(level logrus.Level) pg.QueryHook

func ResolveMigrationsDirectrory

func ResolveMigrationsDirectrory() string

func RunInTransaction

func RunInTransaction(f interface{}) error

func RunInTransactionV2

func RunInTransactionV2(pdb *pg.DB, f interface{}) error

Types

type CrudRepository

type CrudRepository struct {
	DB           orm.DB
	EntityType   reflect.Type
	CastToSlice  func(interface{}) interface{}
	CastToEntity func(interface{}) interface{}
}

func (*CrudRepository) CreateEntity

func (r *CrudRepository) CreateEntity(entity interface{}) (interface{}, error)

func (*CrudRepository) DeleteEntities

func (r *CrudRepository) DeleteEntities(identities []int32) (int, error)

func (*CrudRepository) DeleteLongEntities

func (r *CrudRepository) DeleteLongEntities(identities []int64) (int, error)

func (*CrudRepository) GetAllEntities

func (r *CrudRepository) GetAllEntities(identities []int32) (interface{}, error)

func (*CrudRepository) GetAllLongEntities

func (r *CrudRepository) GetAllLongEntities(identities []int64) (interface{}, error)

func (*CrudRepository) GetEntityById

func (r *CrudRepository) GetEntityById(identity int32) (interface{}, error)

func (*CrudRepository) GetEntityByName

func (r *CrudRepository) GetEntityByName(name string) (interface{}, error)

func (*CrudRepository) UpdateEntity

func (r *CrudRepository) UpdateEntity(entity interface{}) (interface{}, error)

type DBManager

type DBManager struct {
	Db *pg.DB
	// contains filtered or unexported fields
}

func GetDBManager

func GetDBManager() *DBManager

type ErrorEvent

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

func (ErrorEvent) Error

func (er ErrorEvent) Error() string

type Option

type Option func(rdc *RxDbClient)

func WithInitializingErrorHandler

func WithInitializingErrorHandler(eh errorHandler) Option

func WithInitializingHandler

func WithInitializingHandler(handler initHandler) Option

func WithMigrationsEnsuring

func WithMigrationsEnsuring() Option

func WithQueryHooks added in v1.3.0

func WithQueryHooks(qhs ...pg.QueryHook) Option

func WithSchemaAutoInjecting

func WithSchemaAutoInjecting() Option

func WithSchemaEnsuring

func WithSchemaEnsuring() Option

type RxDbClient

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

func NewRxDbClient

func NewRxDbClient(opts ...Option) *RxDbClient

func (*RxDbClient) Close

func (rc *RxDbClient) Close() error

func (*RxDbClient) ReceiveConfiguration

func (rc *RxDbClient) ReceiveConfiguration(config structure.DBConfiguration)

func (*RxDbClient) RunInTransaction

func (rc *RxDbClient) RunInTransaction(f interface{}) error

func (*RxDbClient) Unsafe added in v1.3.0

func (rc *RxDbClient) Unsafe() *pg.DB

func (*RxDbClient) Visit

func (rc *RxDbClient) Visit(v visitor) error

Jump to

Keyboard shortcuts

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