orm

package
v0.0.0-...-84a7560 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDatabaseForMySQL

func OpenDatabaseForMySQL(cfg *DBConfig) (*gorm.DB, error)

func OpenDatabaseForPostgres

func OpenDatabaseForPostgres(cfg *DBConfig) (*gorm.DB, error)

OpenDatabaseForPostgres postgres

Types

type DBConfig

type DBConfig struct {
	DBEnableTLS  bool   `json:"db_enable_tls" mapstructure:"db_enable_tls"`
	DBCaCertPEM  string `json:"db_ca_cert_pem" mapstructure:"db_ca_cert_pem"`
	CustomTLSKey string `json:"db_custom_tls_key" mapstructure:"db_custom_tls_key"`

	DBHost         string `json:"db_host" mapstructure:"db_host"`
	DBUser         string `json:"db_user" mapstructure:"db_user"`
	DBPassword     string `json:"db_password" mapstructure:"db_password"`
	DBName         string `json:"db_name" mapstructure:"db_name"`
	DBConnPoolSize int    `json:"db_conn_pool_size" mapstructure:"db_conn_pool_size"`

	// Dialect default is mysql
	Dialect string  `json:"dialect" mapstructure:"dialect"`
	Loc     LocType `json:"loc" mapstructure:"loc"`

	Debug bool `json:"debug" mapstructure:"debug"`
	// Logger 这里可以替换成我们自己的 logger 实现
	Logger logger.Interface
}

type LocType

type LocType string
const (
	Local LocType = "Local"
	UTC   LocType = "UTC"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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