orm

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DriverPostgres = "postgres"
	DriverMysql    = "mysql"
)

Variables

This section is empty.

Functions

func GetClient

func GetClient(name string) *gorm.DB

GetClient get a redis client

func NewDB added in v0.0.7

func NewDB(c *Config) (db *gorm.DB)

NewDB create a db

Types

type Config

type Config struct {
	Driver          string
	Dsn             string
	Host            string
	Port            int
	User            string
	Password        string
	Database        string
	TablePrefix     string
	Debug           bool
	Trace           bool
	MaxIdleConn     int
	MaxOpenConn     int
	ConnMaxLifeTime time.Duration
	SlowThreshold   time.Duration // 慢查询时长,默认500ms
}

Config mysql config

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager define a db manager

func GetManager

func GetManager() *Manager

GetManager get a redis manager

func NewRManager

func NewRManager() *Manager

NewRManager create a redis manager

func (*Manager) GetClient

func (m *Manager) GetClient(name string) *gorm.DB

GetClient get a redis client

func (*Manager) InitClient

func (m *Manager) InitClient(name string, c *Config)

InitClient init a redis client

type Migration

type Migration struct {
	Version   string    `gorm:"primaryKey"`
	ApplyTime time.Time `gorm:"autoCreateTime"`
}

Migration 数据迁移

func (Migration) TableName

func (Migration) TableName() string

TableName 表名

Jump to

Keyboard shortcuts

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