database

package
v0.0.0-...-d386c04 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CtxTransaction ctxkey = "kanthor.database.transaction"

Variables

View Source
var (
	ErrNotReady         = errors.New("DATABASE.NOT_READY.ERROR")
	ErrNotLive          = errors.New("DATABASE.NOT_LIVE.ERROR")
	ErrAlreadyConnected = errors.New("DATABASE.ALREADY_CONNECTED.ERROR")
	ErrNotConnected     = errors.New("DATABASE.NOT_CONNECTED.ERROR")
	ErrRecordNotFound   = errors.New("DATABASE.RECORD.NOT_FOUND.ERROR")
)

Functions

func NewSqlLogger

func NewSqlLogger(log logging.Logger) logger.Interface

func SqlApplyCountQuery

func SqlApplyCountQuery(tx *gorm.DB, query *entities.PagingQuery, props []string) *gorm.DB

func SqlApplyListQuery

func SqlApplyListQuery(tx *gorm.DB, query *entities.PagingQuery, props []string) *gorm.DB

func SqlTxnFromContext

func SqlTxnFromContext(ctx context.Context, client *gorm.DB) *gorm.DB

Types

type Database

type Database interface {
	patterns.Connectable
	Client() any
}

func New

func New(provider configuration.Provider) (Database, error)

func NewSQL

func NewSQL(conf *config.Config, logger logging.Logger) (Database, error)

type SqlLogger

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

func (*SqlLogger) Error

func (logger *SqlLogger) Error(ctx context.Context, msg string, args ...interface{})

func (*SqlLogger) Info

func (logger *SqlLogger) Info(ctx context.Context, msg string, args ...interface{})

func (*SqlLogger) LogMode

func (logger *SqlLogger) LogMode(logger.LogLevel) logger.Interface

func (*SqlLogger) Trace

func (logger *SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*SqlLogger) Warn

func (logger *SqlLogger) Warn(ctx context.Context, msg string, args ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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