gorm

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MysqlClient

func MysqlClient(c Conf) (*gorm.DB, error)

func PgSqlClient

func PgSqlClient(c Conf) (*gorm.DB, error)

Types

type Conf

type Conf struct {
	Type        string `json:",default=mysql,options=[mysql,postgres]"` // type of database: mysql, postgres
	Host        string `json:",default=localhost"`                      // address
	Port        int    `json:",default=3306"`                           // port
	Config      string `json:",optional"`                               // extra config such as charset=utf8mb4&parseTime=True
	DBName      string `json:",default=simple_admin"`                   // database name
	Username    string `json:",default=root"`                           // username
	Password    string `json:",optional"`                               // password
	MaxIdleConn int    `json:",default=10"`                             // the maximum number of connections in the idle connection pool
	MaxOpenConn int    `json:",default=100"`                            // the maximum number of open connections to the database
	LogMode     string `json:",default=error"`                          // open gorm's global logger
}

Conf is the configuration structure for GORM.

func (Conf) MysqlDSN

func (g Conf) MysqlDSN() string

MysqlDSN returns the MySQL DSN link from the configuration.

func (Conf) NewGORM

func (g Conf) NewGORM() (*gorm.DB, error)

func (Conf) PostgreSqlDSN

func (g Conf) PostgreSqlDSN() string

PostgreSqlDSN returns the PostgreSQL DSN link from the configuration.

Jump to

Keyboard shortcuts

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