context

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

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
}

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)

Jump to

Keyboard shortcuts

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