database

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module(opts ...di.Node) di.Node

func NewGormDB

func NewGormDB(dialecter gorm.Dialector) (*gorm.DB, error)

func NewPostgresDialector

func NewPostgresDialector(config Config) gorm.Dialector

func UseMigrations

func UseMigrations(migrationsDirFS *embed.FS, paths ...string) di.Node

func UseOtelLogger

func UseOtelLogger(opts ...di.Option) di.Node

func UseOtelTraceMetrics

func UseOtelTraceMetrics(opts ...di.Option) di.Node

Types

type Config

type Config struct {
	Dialect    string `mapstructure:"dialect"`
	Migrate    bool   `mapstructure:"migrate"`
	Datasource string `mapstructure:"datasource"`
}

type ContextFn

type ContextFn func(ctx context.Context) []zapcore.Field

type Logger

type Logger struct {
	ZapLogger                 *zap.Logger
	LogLevel                  gormlogger.LogLevel
	SlowThreshold             time.Duration
	SkipCallerLookup          bool
	IgnoreRecordNotFoundError bool
	Context                   ContextFn
	ParameterizedQueries      bool
}

func NewGormLogger

func NewGormLogger(zapLogger *zap.Logger, opts ...Option) Logger

func (Logger) Error

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

func (Logger) Info

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

func (Logger) LogMode

func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface

func (Logger) ParamsFilter

func (l Logger) ParamsFilter(ctx context.Context, sql string, params ...any) (string, []any)

func (Logger) SetAsDefault

func (l Logger) SetAsDefault()

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, str string, args ...any)

type Option

type Option func(*Logger)

func WithParamFilter

func WithParamFilter(on bool) Option

Jump to

Keyboard shortcuts

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