pg

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(m Conf) (*gorm.DB, error)

func ConnectWithConfig

func ConnectWithConfig(m Conf, cfg *gorm.Config) (*gorm.DB, error)

func MustConnect

func MustConnect(m Conf) *gorm.DB

func MustConnectWithConfig

func MustConnectWithConfig(m Conf, cfg *gorm.Config) *gorm.DB

Types

type Conf

type Conf struct {
	Username      string
	Password      string
	Path          string
	Port          int    `json:",default=5432"`
	SslMode       string `json:",default=disable,options=disable|enable"`
	TimeZone      string `json:",default=Asia/Shanghai"`
	Dbname        string
	MaxIdleConns  int    `json:",default=10"`                               // 空闲中的最大连接数
	MaxOpenConns  int    `json:",default=10"`                               // 打开到数据库的最大连接数
	LogMode       string `json:",default=dev,options=dev|test|prod|silent"` // 是否开启Gorm全局日志
	SlowThreshold int64  `json:",default=1000"`
}

func (*Conf) Dsn

func (m *Conf) Dsn() string

func (*Conf) GetColorful

func (m *Conf) GetColorful() bool

func (*Conf) GetGormLogMode

func (m *Conf) GetGormLogMode() logger.LogLevel

func (*Conf) GetSlowThreshold

func (m *Conf) GetSlowThreshold() time.Duration

Jump to

Keyboard shortcuts

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