db

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

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongodb

type Mongodb struct {
	Database string   `toml:"database" yaml:"database" mapstructure:"database" env:"MONGODB_DATABASE"`
	UserName string   `toml:"username" yaml:"username" mapstructure:"username" env:"MONGODB_USERNAME"`
	Password string   `toml:"password" yaml:"password" mapstructure:"password" env:"MONGODB_PASSWORD"`
	Host     []string `toml:"host" yaml:"host" mapstructure:"host" env:"MONGODB_HOST"`
}

func NewDefaultMongoDB

func NewDefaultMongoDB() *Mongodb

type Mysql

type Mysql struct {
	ClientName  string `toml:"client_name" yaml:"client_name" mapstructure:"client_name" env:"MYSQL_NAME"`
	Host        string `toml:"host" yaml:"host" mapstructure:"host" env:"MYSQL_HOST"`
	Port        string `toml:"port" yaml:"port" mapstructure:"port" env:"MYSQL_PORT"`
	UserName    string `toml:"username" yaml:"username" mapstructure:"username" env:"MYSQL_USERNAME"`
	Password    string `toml:"password" yaml:"password" mapstructure:"password" env:"MYSQL_PASSWORD"`
	Database    string `toml:"database" yaml:"database" mapstructure:"database" env:"MYSQL_DATABASE"`
	MaxOpenConn int    `toml:"max_open_conn" yaml:"max_open_conn" mapstructure:"max_open_conn" env:"MYSQL_MAX_OPEN_CONN"`
	MaxIdleConn int    `toml:"max_idle_conn" yaml:"max_idle_conn" mapstructure:"max_idle_conn" env:"MYSQL_MAX_IDLE_CONN"`
	MaxLifeTime int    `toml:"max_life_time" yaml:"max_life_time" mapstructure:"max_life_time" env:"MYSQL_MAX_LIFE_TIME"`
	MaxIdleTime int    `toml:"max_idle_time" yaml:"max_idle_time" mapstructure:"max_idle_time" env:"MYSQL_MAX_IDLE_TIME"`
	TablePrefix string `toml:"table_prefix" yaml:"table_prefix" mapstructure:"table_prefix" env:"MYSQL_TABLE_PREFIX"`
	LogFileName string `toml:"log_file_name" yaml:"log_file_name" mapstructure:"log_file_name" env:"MYSQL_LOG_FILE_NAME"`

	LogLevel logger.LogLevel
	// contains filtered or unexported fields
}

func NewDefaultMysql

func NewDefaultMysql() *Mysql

func (*Mysql) GetDB

func (m *Mysql) GetDB() *gorm.DB

GetDB 获取 gorm 对象

func (*Mysql) GetSqlDB

func (m *Mysql) GetSqlDB() (*sql.DB, error)

GetSqlDB 获取 sql 对象

func (*Mysql) InitDB

func (m *Mysql) InitDB() error

type Redis

type Redis struct {
	Host        string `toml:"host" yaml:"host" mapstructure:"host" env:"REDIS_HOST"`
	Password    string `toml:"password" yaml:"password" mapstructure:"password" env:"REDIS_PASSWORD"`
	Database    int    `toml:"database" yaml:"database" mapstructure:"database" env:"REDIS_DATABASE"`
	MinIdleConn int    `toml:"min_idle_conn" yaml:"min_idle_conn" mapstructure:"min_idle_conn" env:"REDIS_MIN_IDLE_CONN"`
	PoolSize    int    `toml:"pool_size" yaml:"pool_size" mapstructure:"pool_size" env:"REDIS_POOL_SIZE"`
	MaxRetries  int    `toml:"max_retries" yaml:"max_retries" mapstructure:"max_retries" env:"REDIS_MAX_RETRIES"`
}

func NewDefaultRedis

func NewDefaultRedis() *Redis

Jump to

Keyboard shortcuts

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