dbengine

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.Errorf("resource not found")
)

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        uint64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Conf

type Conf struct {
	MySQLURL          string `env:"MYSQL_URL"`
	MySQLHost         string `env:"MYSQL_HOST"`
	MySQLPort         string `env:"MYSQL_PORT"`
	MySQLUsername     string `env:"MYSQL_USERNAME"`
	MySQLPassword     string `env:"MYSQL_PASSWORD"`
	MySQLDatabase     string `env:"MYSQL_DATABASE"`
	MySQLCharset      string `env:"MYSQL_CHARSET" default:"utf8mb4"`
	MySQLMaxIdleConns int    `env:"MYSQL_MAXIDLECONNS"`
	MySQLMaxOpenConns int    `env:"MYSQL_MAXOPENCONNS"`
	MySQLMaxLifeTime  int64  `env:"MYSQL_MAXLIFETIME"` // 单位秒 (s)
	Debug             bool   `env:"DEBUG"`
}

func LoadDefaultConf

func LoadDefaultConf() (*Conf, error)

type DBEngine

type DBEngine struct {
	*gorm.DB
}

func MustOpen

func MustOpen(c ...*Conf) *DBEngine

MustOpen 强制打开,err 时 panic

func Open

func Open(c ...*Conf) (*DBEngine, error)

Open 构造引擎,打开数据库连接池

func (*DBEngine) Close

func (e *DBEngine) Close() error

Close 关闭数据库连接池

Jump to

Keyboard shortcuts

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