db

package
v0.0.0-...-9b663ca Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEBUG = env.GetEnvBool("DEBUG", true)
)

环境变量

Functions

func GetDB

func GetDB(config ...*DBConfig) *gorm.DB

GetDB get db connection

func TablePrefix

func TablePrefix() string

TablePrefix 获取表前缀

func Trx

func Trx(handle func(tx *gorm.DB) error) (err error)

封装事务操作,处理panic

Types

type DBConfig

type DBConfig struct {
	Server       string `yaml:"server" json:"server"`
	Driver       string `yaml:"driver" json:"driver"`
	Host         string `yaml:"host" json:"host"`
	Port         uint   `yaml:"port" json:"port"`
	User         string `yaml:"user" json:"user"`
	Password     string `yaml:"password" json:"password"`
	Name         string `yaml:"name" json:"name"`
	MaxIdleConns uint   `yaml:"max_idle_conns" json:"max_idle_conns"`
	MaxOpenConns uint   `yaml:"max_open_conns" json:"max_open_conns"`
	EnableLog    bool   `yaml:"enable_log" json:"enable_log"`
}

DBConfig config of relational database

Jump to

Keyboard shortcuts

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