database

package
v0.0.0-...-2ff8efa Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = errors.New("record not found")
	ErrKeyConflict = errors.New("key conflict")
)

Functions

func DeleteRecordAll

func DeleteRecordAll(_ testing.TB, db *gorm.DB, tableWhereClauses []string) error

func IsKeyConflictErr

func IsKeyConflictErr(err error) bool

func IsRecordNotFoundErr

func IsRecordNotFoundErr(err error) bool

func NewDatabase

func NewDatabase(cfg *config.Config) (*gorm.DB, error)

NewDatabase creates a new database with given config

func NewTestDatabase

func NewTestDatabase(tb testing.TB, migration bool) *gorm.DB

Types

type Logger

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

func NewLogger

func NewLogger(slowThreshold time.Duration, ignoreRecordNotFoundError bool, level zapcore.Level) *Logger

NewLogger returns a new logger for gorm. *zap.SugaredLogger will use from context.Context.

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, i ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(level glogger.LogLevel) glogger.Interface

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})

Jump to

Keyboard shortcuts

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