mysql

package
v1.1.28 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mysql provides a gorm driver for mysql.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db *gorm.DB) error

Close close gorm db

func Init

func Init(dsn string, opts ...Option) (*gorm.DB, error)

Init mysql

func InitTidb

func InitTidb(dsn string, opts ...Option) (*gorm.DB, error)

InitTidb init tidb

Types

type Option

type Option func(*options)

Option set the mysql options.

func WithConnMaxLifetime

func WithConnMaxLifetime(t time.Duration) Option

WithConnMaxLifetime set conn max lifetime

func WithEnableForeignKey

func WithEnableForeignKey() Option

WithEnableForeignKey use foreign keys

func WithEnableTrace

func WithEnableTrace() Option

WithEnableTrace use trace

func WithGormPlugin

func WithGormPlugin(plugins ...gorm.Plugin) Option

WithGormPlugin setting gorm plugin

func WithLogRequestIDKey

func WithLogRequestIDKey(key string) Option

WithLogRequestIDKey log request id

func WithLogging

func WithLogging(l *zap.Logger, level ...logger.LogLevel) Option

WithLogging set log sql, If l=nil, the gorm log library will be used

func WithMaxIdleConns

func WithMaxIdleConns(size int) Option

WithMaxIdleConns set max idle conns

func WithMaxOpenConns

func WithMaxOpenConns(size int) Option

WithMaxOpenConns set max open conns

func WithRWSeparation

func WithRWSeparation(slavesDsn []string, mastersDsn ...string) Option

WithRWSeparation setting read-write separation

func WithSlowThreshold

func WithSlowThreshold(d time.Duration) Option

WithSlowThreshold Set sql values greater than the threshold

Jump to

Keyboard shortcuts

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