context

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DBManager dBManager = 1

DBManager Developers get raw DB struct

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(db *sqlx.DB) *initiator

func BootstrapDual

func BootstrapDual(write *sqlx.DB, read *sqlx.DB) *initiator

func NewDefaultQueryClient

func NewDefaultQueryClient(identifier string, queryMap *entity.QueryMap, statementMap map[entity.Path]*sqlx.NamedStmt, readOnly bool) *defaultQueryClient

Types

type ApplicationContext

type ApplicationContext interface {
	GetQueryClient(identifier string) (QueryClient, errors.Error)
	GetReadOnlyQueryClient(identifier string) (ReadOnlyQueryClient, errors.Error)
	RegisterQueryClient(client QueryClient) errors.Error
	GetDBs() *entity.DbSet
	GetDB(readDB bool) *sqlx.DB
	GetTxManager() TxManager
}

func GetApplicationContext

func GetApplicationContext() ApplicationContext

type QueryClient

type QueryClient interface {
	ReadOnlyQueryClient
	InsertOne(ctx context.Context, tagName string, args map[string]any, conditions ...entity.PredicateConditions) errors.Error
	InsertOneTx(ctx context.Context, tx *sqlx.Tx, tagName string, args map[string]any, conditions ...entity.PredicateConditions) errors.Error

	Delete(ctx context.Context, tagName string, args map[string]any, conditions ...entity.PredicateConditions) (int64, errors.Error)
	DeleteTx(ctx context.Context, tx *sqlx.Tx, tagName string, args map[string]any, conditions ...entity.PredicateConditions) (int64, errors.Error)

	Update(ctx context.Context, tagName string, args map[string]any, conditions ...entity.PredicateConditions) (int64, errors.Error)
	UpdateTx(ctx context.Context, tx *sqlx.Tx, tagName string, args map[string]any, conditions ...entity.PredicateConditions) (int64, errors.Error)
}

func NewQueryClient

func NewQueryClient(identifier string, filePath string) (QueryClient, errors.Error)

type ReadOnlyQueryClient

type ReadOnlyQueryClient interface {
	BeginTx(ctx context.Context) (*sqlx.Tx, errors.Error)
	RollbackTx(ctx context.Context, tx *sqlx.Tx) errors.Error
	CommitTx(ctx context.Context, tx *sqlx.Tx) errors.Error

	GetOne(ctx context.Context, tagName string, dest any, args map[string]any, conditions ...entity.PredicateConditions) errors.Error
	GetOneTx(ctx context.Context, tx *sqlx.Tx, tagName string, dest any, args map[string]any, conditions ...entity.PredicateConditions) errors.Error
	Get(ctx context.Context, tagName string, dest any, args map[string]any, conditions ...entity.PredicateConditions) errors.Error
	GetTx(ctx context.Context, tx *sqlx.Tx, tagName string, dest any, args map[string]any, conditions ...entity.PredicateConditions) errors.Error

	Id() string
	ReadOnly() bool
}

func NewReadOnlyQueryClient

func NewReadOnlyQueryClient(identifier string, filePath string) (ReadOnlyQueryClient, errors.Error)

type TxBlock added in v1.1.0

type TxBlock func(ctx context.Context, tx *sqlx.Tx) error

type TxBlockAuto added in v1.1.1

type TxBlockAuto func(ctx context.Context) error

type TxManager added in v1.1.0

type TxManager interface {
	Txx(ctx context.Context, txBlock TxBlockAuto) errors.Error
	TxxWithOpt(ctx context.Context, opts *sql.TxOptions, txBlock TxBlockAuto) errors.Error
	Tx(ctx context.Context, txBlock TxBlock) errors.Error
	TxWithOpt(ctx context.Context, opts *sql.TxOptions, txBlock TxBlock) errors.Error
}

func NewTxManager added in v1.1.0

func NewTxManager(writeDB *sqlx.DB) TxManager

Jump to

Keyboard shortcuts

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