database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: GPL-3.0 Imports: 18 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 CloseReadOnly

func CloseReadOnly()

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 InitReadOnlyDbV2

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

func InitReadOnlyDbV2WithSchema

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

func InitReadOnlyDbWithCurrentSchema

func InitReadOnlyDbWithCurrentSchema(config structure.DBConfiguration)

func InitReadOnlyDbWithSchema

func InitReadOnlyDbWithSchema(config structure.DBConfiguration, schema string)

func NewDbConnection

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

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

func GetReadOnlyDBManager

func GetReadOnlyDBManager() *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 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) 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