godb

package
v0.0.0-...-2c6e621 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MysqlDB mysql
	MysqlDB dBType = iota
	// PgDB postgresql
	PgDB
)

Variables

View Source
var (
	// ErrUnknownDBType unknown db type
	ErrUnknownDBType = errors.New("unknown db type")
)

Functions

func NewMysqlDB

func NewMysqlDB(dbConfig *Config) (*gorm.DB, error)

NewMysqlDB return mysql db

func NewPgDB

func NewPgDB(dbConfig *Config) (*gorm.DB, error)

NewPgDB return postgresql db

Types

type Config

type Config struct {
	User            string
	Password        string
	Host            string
	Port            int
	DB              string
	MaxIdleConns    int `mapstructure:"max_idle_conns"`
	MaxOpenConns    int `mapstructure:"max_open_conns"`
	MaxLifeTime     int `mapstructure:"max_life_time"`
	Logger          *zap.Logger
	Level           string
	SlowThreshold   int `mapstructure:"slow_threshold"`
	SQLLenThreshold int `mapstructure:"sql_len_threshold"`
}

Config db config

Jump to

Keyboard shortcuts

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