db

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Default *gorm.DB //默认数据库
)

Functions

func Add

func Add(name string, option Option)

func AddMap

func AddMap(name string, setting map[string]interface{})

func AddMapBatch

func AddMapBatch(batch map[string]interface{})

func Use

func Use(name string) *gorm.DB

Use 使用

Types

type Option

type Option struct {
	DSN           string `json:"dsn"`            //数据源
	Driver        string `json:"driver"`         //驱动,mysql、postgres、sqlite、sqlserver、clickhouse,默认mysql
	MaxOpenConn   int    `json:"max_open_conn"`  //打开连接的最大数量,默认100
	MaxIdleConn   int    `json:"max_idle_conn"`  //空闲连接的最大数量,默认10
	LogLevel      int    `json:"log_level"`      //Silent 1、Error 2、Warn 3、Info 4,默认3
	SlowThreshold int    `json:"slow_threshold"` //慢SQL阈值,单位秒,默认1
}

Jump to

Keyboard shortcuts

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