orm

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorsDbDriverNotExists   = "Database.Type 数据库驱动不被支持,请选择mysql|postgres:"
	ErrorsDialectorDbInitFail = "数据库驱动初始化失败:"
	EventDestroyPrefix        = "Destroy_Database"
)

Variables

This section is empty.

Functions

func GetSqlDriver

func GetSqlDriver(options *DbOptions, wl winner_logger.Logger, tracing bool) (*gorm.DB, error)

获取数据库驱动 ops := &DbOptions wl winner_logger.Logger tracing 是否开启sql日志

func NewMysqlTracingPlugin added in v1.0.1

func NewMysqlTracingPlugin(logger winner_logger.Logger) gorm.Plugin

func ParseDsn added in v1.0.2

func ParseDsn(sqlType, originDsn string) string

Types

type DbOptions

type DbOptions struct {
	SqlType        string
	Dsn            string
	Replicas       []string
	EnableReplicas bool
	MaxIdle        int
	MaxIdleTime    time.Duration
	MaxLifeTime    time.Duration
	MaxOpen        int
	SlowThreshold  time.Duration
}

type LocalTime

type LocalTime struct {
	time.Time
}

自定义日期对象,解决gorm日期的自动序列化问题

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

Scan valueof time.Time

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

type WinnerTracingPlugin added in v1.0.1

type WinnerTracingPlugin struct{}

func (*WinnerTracingPlugin) Initialize added in v1.0.1

func (op *WinnerTracingPlugin) Initialize(db *gorm.DB) (err error)

func (*WinnerTracingPlugin) Name added in v1.0.1

func (op *WinnerTracingPlugin) Name() string

Jump to

Keyboard shortcuts

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