database

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedDriver is returned when specified database driver does not exists.
	ErrUnsupportedDriver = errors.New("unsupported database driver")
)

Functions

func FxModule

func FxModule() fx.Option

func New

func New(
	cfg *configs.Database,
	slogLogger *slog.Logger,
	clock time.Clock,
) (db *gorm.DB, err error)

Types

type Logger

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

Logger is used to replace the default Gorm logger.

func (Logger) Error

func (l Logger) Error(ctx context.Context, msg string, args ...any)

Error allows to print a new error message.

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, args ...any)

Info allows to print a new informational message.

func (Logger) LogMode

func (l Logger) LogMode(lvl gorml.LogLevel) gorml.Interface

LogMode allows to set the current log level.

func (Logger) Trace

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

Trace allows to print a new trace message.

func (Logger) Warn

func (l Logger) Warn(ctx context.Context, msg string, args ...any)

Warn allows to print a new warning message.

type Transaction

type Transaction interface {
	DB() *gorm.DB
	Commit() error
	Rollback() error
}

type TransactionManager

type TransactionManager interface {
	New() Transaction
}

func NewTransactionManager

func NewTransactionManager(db *gorm.DB) TransactionManager

Jump to

Keyboard shortcuts

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