gorm

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMysql added in v0.3.1

func NewMysql(config *Config, tables []interface{}) (*gorm.DB, error)

func WithPagingFilter added in v0.3.0

func WithPagingFilter(sql *gorm.DB, page, size uint64)

Types

type Config added in v0.3.1

type Config struct {
	Tls TLS `json:"tls" bson:"tls" yaml:"tls" mapstructure:"tls"`

	Prefix   string `json:"prefix" bson:"prefix" yaml:"prefix" mapstructure:"prefix"`
	Account  string `json:"account" bson:"account" yaml:"account" mapstructure:"account"`
	Password string `json:"password" bson:"password" yaml:"password" mapstructure:"password"`

	Address  string `json:"address" yaml:"address" mapstructure:"address"`
	Database string `json:"database" yaml:"database" mapstructure:"database"`

	Mode bool `json:"mode" yaml:"mode" mapstructure:"mode"` // Mode is true cluster

	MaxOpenConnects        int  `json:"max_open_connects" bson:"max_open_connects" yaml:"max_open_connects" mapstructure:"max_open_connects"`
	MaxIdleConnects        int  `json:"max_idle_connects" bson:"max_idle_connects" yaml:"max_idle_connects" mapstructure:"max_idle_connects"`
	ConnMaxLifeTime        int  `json:"conn_max_life_time" bson:"conn_max_life_time" yaml:"conn_max_life_time" mapstructure:"conn_max_life_time"`
	SkipDefaultTransaction bool `` /* 135-byte string literal not displayed */
	PrepareStmt            bool `json:"prepare_stmt" bson:"prepare_stmt" yaml:"prepare_stmt" mapstructure:"prepare_stmt"`

	LoggerEnable bool `json:"logger_enable" bson:"logger_enable" yaml:"logger_enable" mapstructure:"logger_enable"`
	// contains filtered or unexported fields
}

func (*Config) WithAutoMigrate added in v0.3.1

func (config *Config) WithAutoMigrate(state bool)

func (*Config) WithLoggerConsole added in v0.3.1

func (config *Config) WithLoggerConsole(state bool)

func (*Config) WithLoggerHandle added in v0.3.1

func (config *Config) WithLoggerHandle(handle func(b []byte))

type TLS added in v0.3.1

type TLS struct {
	CaCert        string `json:"ca_cert" bson:"ca_cert" yaml:"ca_cert" mapstructure:"ca_cert"`
	ClientCert    string `json:"client_cert" bson:"client_cert" yaml:"client_cert" mapstructure:"client_cert"`
	ClientCertKey string `json:"client_cert_key" bson:"client_cert_key" yaml:"client_cert_key" mapstructure:"client_cert_key"`
}

type Table added in v0.3.1

type Table struct {
	ID        uint           `json:"id" gorm:"primarykey"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

type TableUUID added in v0.3.1

type TableUUID struct {
	ID        string         `json:"id" gorm:"primarykey;size:36;"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

func (*TableUUID) BeforeCreate added in v0.3.1

func (s *TableUUID) BeforeCreate(_ *gorm.DB) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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