mysql

package
v0.0.0-...-6fe9b21 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultName = "default"
)

Variables

View Source
var AppDatabase = &database{
	pool: make(map[string]*gorm.DB),
}

Functions

func Assign

func Assign(name string, config Config, plugins ...gorm.Plugin) error

Assign 加载数据库

func CloseHook

func CloseHook() func()

CloseHook 优雅关闭

func DBLimit

func DBLimit(pageNum int, pageSize int) func(db *gorm.DB) *gorm.DB

DBLimit sql limit

func GetGormDB

func GetGormDB(ctx context.Context, name string) (*gorm.DB, error)

func SetMaxPageSize

func SetMaxPageSize(pageSize int)

func SetPageSize

func SetPageSize(pageSize int)

Types

type Config

type Config struct {
	Url         string `json:"url"`         // 地址
	Mode        bool   `json:"mode"`        // 运行模式 TRUE开启调试模式
	MaxIdle     int    `json:"maxIdle"`     // 最大闲置连接数
	MaxOpen     int    `json:"maxOpen"`     // 最大连接数
	MaxLifetime int    `json:"maxLifetime"` //最大周期
	Prefix      string `json:"prefix"`      //表前缀
}

Config 数据库配置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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