orm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CSTLayout = "2006-01-02 15:04:05"

CSTLayout China Standard Time Layout

Variables

View Source
var GlobalGormTrace gorm.Plugin = &TracePlugin{}

Functions

func CSTLayoutString

func CSTLayoutString() string

func OpenDB

func OpenDB(conf Config) (*gorm.DB, error)

func ShowDbStatus

func ShowDbStatus(gdb *gorm.DB)

Types

type Config

type Config struct {
	SQLName     string `json:"sqlName"`
	Account     string `json:"account"`
	Password    string `json:"password"`
	Address     string `json:"address"`
	Port        int    `json:"port"`
	Database    string `json:"database"`
	MaxIdleConn int    `json:"maxIdleConn"`
	MaxOpenConn int    `json:"maxOpenConn"`
	MaxLifetime int    `json:"maxLIfetime"` // unit - second
	IsTrace     bool   `json:"isTrace"`
}

SQL Config of db.

type SqlTraceInfo

type SqlTraceInfo struct {
	Timestamp   string  `json:"timestamp"`     // time, format like:2006-01-02 15:04:05
	Stack       string  `json:"stack"`         // file address and line number
	SQL         string  `json:"sql"`           // SQL statement
	Rows        int64   `json:"rows_affected"` // Number of rows affected
	CostSeconds float64 `json:"cost_seconds"`  // Execution time (in seconds)
}

type TracePlugin

type TracePlugin struct{}

func (*TracePlugin) Initialize

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

func (*TracePlugin) Name

func (op *TracePlugin) Name() string

Jump to

Keyboard shortcuts

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