gorm

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Profile = "gorm"

Variables

View Source
var DatabaseIsNotOpenedError = errors.New("database is not opened")

Functions

This section is empty.

Types

type Config

type Config struct {
	Decrypt    bool   `json:"decrypt" default:"true"`
	DecryptKey string `json:"decrypt_key"`
}

type DataSource

type DataSource interface {
	Open(p *Properties) error
	IsOpened() bool
	Close() error
	Repository() gorm.Repository
}

func GetDataSource

func GetDataSource() DataSource

type Properties added in v1.3.0

type Properties struct {
	// annotation ConfigurationProperties
	at.ConfigurationProperties `value:"gorm"`

	Type            string `json:"type" default:"mysql"` // mysql, postgres, sqlite3, mssql,
	Host            string `json:"host" default:"mysql-dev"`
	Port            string `json:"port" default:"3306"`
	Database        string `json:"database"`
	Username        string `json:"username"`
	Password        string `json:"password"`
	Charset         string `json:"charset" default:"utf8"`
	ParseTime       bool   `json:"parse_time" default:"true"`
	Loc             string `json:"loc" default:"Asia/Shanghai"`
	Config          Config `json:"config"`
	ConnMaxLifetime string `json:"connMaxLifetime" default:"60s"`
	MaxIdleConns    int    `json:"maxIdle_conns" default:"20"`
	MaxOpenConns    int    `json:"maxOpen_conns" default:"200"`
	AutoReconnect   bool   `json:"auto_reconnect" default:"true"`
	RetryTimes      int    `json:"retry_times" default:"-1"`
	Interval        string `json:"interval" default:"3s"`
	NowRetryTimes   int    `json:"now_retry_times" default:"0"`
}

type Repository

type Repository interface {
	gorm.Repository
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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