mysql

package
v0.0.0-...-768fa91 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyQueryOpts

func ApplyQueryOpts(db *gorm.DB, opts ...QueryOptFunc) *gorm.DB

func Close

func Close()

func GetDB

func GetDB() *gorm.DB

func InitMySql

func InitMySql(c *MySqlConfig)

Types

type FuncOpts

type FuncOpts func(l *customizedLogger)

func WithColor

func WithColor(color bool) FuncOpts

func WithLogLevel

func WithLogLevel(level logger.LogLevel) FuncOpts

func WithLogger

func WithLogger(logger xlogger.Logger) FuncOpts

func WithRecordNotFound

func WithRecordNotFound(i bool) FuncOpts

func WithSlowThreshold

func WithSlowThreshold(tm time.Duration) FuncOpts

type MySqlConfig

type MySqlConfig struct {
	Address       string `json:"address"`
	MaxIdleConn   int    `json:"max_idle_conn"`
	MaxOpenConn   int    `json:"max_open_conn"`
	MaxLifeTime   int    `json:"max_life_time"`
	MaxIdleTime   int    `json:"max_idle_time"`
	LogMode       int    `json:"log_mode"` //默认warn
	CustomizedLog bool   `json:"customized_log"`
	xlogger.Logger
}

type QueryOptFunc

type QueryOptFunc func(*QueryOption)

func Limit

func Limit(limit int) QueryOptFunc

func Order

func Order(order ...string) QueryOptFunc

func Skip

func Skip(skip int) QueryOptFunc

type QueryOption

type QueryOption struct {
	Skip  int
	Limit int
	Order []string
}

Jump to

Keyboard shortcuts

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