db

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(conf Config) (*gorm.DB, error)

New database instance

Types

type Config

type Config struct {
	Writer                       ConfigNode    `mapstructure:"writer"`
	Reader                       ConfigNode    `mapstructure:"reader"`
	Database                     string        `mapstructure:"database"`
	Timezone                     string        `mapstructure:"timezone"`
	ConnMaxIdleTime              time.Duration `mapstructure:"conn_max_idle_time"`
	ConnMaxLifetime              time.Duration `mapstructure:"conn_max_lifetime"`
	MaxIdleConns                 int           `mapstructure:"max_idle_conns"`
	MaxOpenConns                 int           `mapstructure:"max_open_conns"`
	LogSlowThreshold             time.Duration `mapstructure:"log_slow_threshold"`
	LogColorful                  bool          `mapstructure:"log_colorful"`
	LogIgnoreRecordNotFoundError bool          `mapstructure:"log_ignore_record_not_found_error"`
	LogLevel                     string        `mapstructure:"log_level"`
}

type ConfigNode

type ConfigNode struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

Jump to

Keyboard shortcuts

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