database

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataBase

func NewDataBase(
	driver, host string,
	port uint, dbname, instanceName string,
	user, password string, sslmode bool,
	connectTimeout, readTimeout, writeTimeout string,
	dialTimeout time.Duration,
	options ...Option,
) (*gorm.DB, error)

Types

type DataSourceTypeName

type DataSourceTypeName string
const (
	CloudMySql DataSourceTypeName = "cloud_mysql"
	Mysql      DataSourceTypeName = "mysql"
	Postgresql DataSourceTypeName = "postgres"
	Sqlite     DataSourceTypeName = "sqlite"
)

type Option

type Option interface {
	Apply(*gorm.DB) error
}

An Option configures a gorm.DB

func SetConnMaxIdleTime added in v1.2.0

func SetConnMaxIdleTime(maxIdleTime time.Duration) Option

func SetConnMaxLifetime

func SetConnMaxLifetime(maxlifetime time.Duration) Option

func SetLogLevel

func SetLogLevel(logLevel logger.LogLevel) Option

func SetLogger

func SetLogger(logger logger.Interface) Option

func SetMaxIdleConns

func SetMaxIdleConns(maxIdleConns int) Option

func SetMaxOpenConns

func SetMaxOpenConns(maxOpenConns int) Option

type OptionFunc

type OptionFunc func(*gorm.DB) error

OptionFunc is a function that configures a gorm.DB

func (OptionFunc) Apply

func (f OptionFunc) Apply(engine *gorm.DB) error

Apply is a function that set value to gorm.DB

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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