db

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDB

func GetDB(configFile ...string) *gorm.DB

func NewGormDB

func NewGormDB(options *MySqlOptions, isNew ...*bool) (*gorm.DB, error)

NewGormDB 新建数据库连接

func RegisterDbInitor

func RegisterDbInitor(initor DatabaseInitor)

RegisterDbInitor 注册数据初始化

func Transaction

func Transaction(entry func(tx *gorm.DB) error) error

Transaction 使用事务调用

Types

type DatabaseInitor

type DatabaseInitor func(db *gorm.DB, dbName string)

type MySqlConnectionPool

type MySqlConnectionPool struct {
	MaxOpenConns int // 允许打开的最大连接数
	MaxIdleConns int // 允许空闲的最大连接数
}

type MySqlOptions

type MySqlOptions struct {
	Host     string
	Port     int
	User     string
	DbName   string
	Password string
	Charset  string
	Loc      string
	Pool     *MySqlConnectionPool
	LogLevel string
}

func NewMySqlOptions

func NewMySqlOptions(configRoot string, cfg *viper.Viper) *MySqlOptions

func (*MySqlOptions) String

func (mo *MySqlOptions) String() string

Directories

Path Synopsis
dbheper
dbtype

Jump to

Keyboard shortcuts

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