storage

package
v0.0.0-...-a3456bb Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DBDriverMysql is a const value of mysql driver.
	DBDriverMysql = "mysql"
	// DBDriverSqlite is a const value of sqlite driver.
	DBDriverSqlite = "sqlite"
	// DBDriverPostgresql is a const value of postgresql driver.
	DBDriverPostgresql = "postgresql"
	// DBDriverMssql is a const value of mssql driver.
	DBDriverMssql = "mssql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Driver       string `json:"driver",yaml:"driver",ini:"driver"`
	Host         string `json:"host",yaml:"host",ini:"host"`
	Port         string `json:"port",yaml:"port",ini:"port"`
	User         string `json:"user",yaml:"user",ini:"user"`
	Pwd          string `json:"pwd",yaml:"pwd",ini:"pwd"`
	DatabaseName string `json:"database_name",yaml:"database_name",ini:"database_name"`
	MaxIdleCon   int    `json:"max_idle_con",yaml:"max_idle_con",ini:"max_idle_con"`
	MaxOpenCon   int    `json:"max_open_con",yaml:"max_open_con",ini:"max_open_con"`
	File         string `json:"file",yaml:"file",ini:"file"`
	Dsn          string `json:"dsn",yaml:"dsn",ini:"dsn"`
}

Database is a type of database connection config.

Because a little difference of different database driver. The Config has multiple options but may not be used. Such as the sqlite driver only use the File option which can be ignored when the driver is mysql.

If the Dsn is configured, when driver is mysql/postgresql/ mssql, the other configurations will be ignored, except for MaxIdleCon and MaxOpenCon.

Ref: https://github.com/GoAdminGroup/go-admin/blob/master/modules/config/config.go

type DatabaseList

type DatabaseList map[string]Database

DatabaseList is a map of Database.

func (DatabaseList) Add

func (d DatabaseList) Add(key string, db Database)

Add add a Database to the DatabaseList.

func (DatabaseList) GetDefault

func (d DatabaseList) GetDefault() Database

GetDefault get the default Database.

func (DatabaseList) GroupByDriver

func (d DatabaseList) GroupByDriver() map[string]DatabaseList

GroupByDriver group the Databases with the drivers.

func (DatabaseList) MakeDefault

func (d DatabaseList) MakeDefault(db Database)

MakeDefault a default database config

Jump to

Keyboard shortcuts

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