gorms

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 11 Imported by: 0

README

gormhelper

gorm helper package

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mysql

func Mysql(cfg Config) gorm.Dialector

func Open

func Open(option ...Option) (*gorm.DB, error)

func Postgres

func Postgres(cfg Config) gorm.Dialector

func SQLServer

func SQLServer(cfg Config) gorm.Dialector

func SQLite

func SQLite(cfg Config) gorm.Dialector

Types

type Config

type Config struct {
	Driver   string `mapstructure:"driver"`
	Address  string `mapstructure:"address"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	Database string `mapstructure:"database"`
	Params   string `mapstructure:"param"`
}

type GormLogger added in v1.2.0

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

GormLogger customizes gorm sql logger

func (*GormLogger) Error added in v1.2.0

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

func (*GormLogger) Info added in v1.2.0

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

func (*GormLogger) LogMode added in v1.2.0

func (g *GormLogger) LogMode(level logger.LogLevel) logger.Interface

func (*GormLogger) Trace added in v1.2.0

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

func (*GormLogger) Warn added in v1.2.0

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

type Helper

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

type LoggerOption added in v1.2.2

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

LoggerOption is gorm logger option

func NewLogger added in v1.2.2

func NewLogger(logger *slog.Logger) LoggerOption

func (LoggerOption) AfterInitialize added in v1.2.2

func (l LoggerOption) AfterInitialize(db *gorm.DB) error

func (LoggerOption) Apply added in v1.2.2

func (l LoggerOption) Apply(config *gorm.Config) error

type Option

type Option func(helper *Helper)

func WithContext

func WithContext(ctx context.Context) Option

func WithDriver

func WithDriver(dialector gorm.Dialector) Option

func WithOption

func WithOption(opts ...gorm.Option) Option

Jump to

Keyboard shortcuts

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