xgorm

package
v1.27.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModelToMap added in v1.21.7

func ModelToMap(m Model) map[string]any

func ModelToMapWithTag added in v1.25.7

func ModelToMapWithTag(m Model, tag string) map[string]any

func NewMysqlDB

func NewMysqlDB(cfg *DatabaseConfig) (*gorm.DB, error)

func NewMysqlDBByDsn added in v1.25.8

func NewMysqlDBByDsn(dsn string, cfg *ConnConfig, l logger.Interface) (*gorm.DB, error)

func SetCallBacks added in v1.22.5

func SetCallBacks(db *gorm.DB, callbacks ...Callback) error

Types

type Callback

type Callback struct {
	Name      string
	Action    string
	SortName  string
	SortValue string
	Callback  func(db *gorm.DB) `json:"-"`
}

func (Callback) Valid

func (c Callback) Valid() error

type ConnConfig added in v1.25.8

type ConnConfig struct {
	Debug       bool
	MaxOpenConn int
	MaxLifeTime time.Duration
	MaxIdleConn int
	MaxIdleTime time.Duration
}

type DatabaseConfig

type DatabaseConfig struct {
	Host         string
	Port         int
	Dbname       string
	Charset      string
	User         string
	Password     string
	ReadTimeout  int
	WriteTimeout int
	Timeout      int
	Debug        bool
	Loc          string
	// 连接设置
	MaxOpenConn int
	MaxLifeTime time.Duration
	MaxIdleConn int
	MaxIdleTime time.Duration
}

type Model added in v1.21.7

type Model interface {
	TableName() string
}

Jump to

Keyboard shortcuts

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