Documentation
¶
Index ¶
- Variables
- func CustomQueryWithRows(database *gorm.DB, sql string, ret interface{}) (err error)
- func GenReqID() string
- func Get(xReqID ...string) *gorm.DB
- func GetJSON(obj interface{}) interface{}
- func GetWithAlias(alias string, xReqID ...string) *gorm.DB
- func RegisterDatabase(drivers ...Driver)
- type Array
- type Driver
- type H
- type LogWriter
- type Logger
- type Map
Constants ¶
This section is empty.
Variables ¶
View Source
var NowFunc = func() time.Time { return time.Now() }
NowFunc returns current time, this function is exported in order to be able to give the flexibility to the developer to customize it according to their needs, e.g:
NowFunc = func() time.Time { return time.Now().UTC() }
Functions ¶
func CustomQueryWithRows ¶
CustomQueryWithRows 自定义查询,返回 rows, 并解析 rows 数据到传入的 []struct
func GetWithAlias ¶
GetWithAlias return DB from database cache with alias
Types ¶
type Array ¶
type Array []interface{}
Array MySQL json/array type usage eg.
type User struct { ID uint Name string Tags db.Array `gorm:"type:json"` }
func (Array) StringArray ¶
StringArray convert db Array to string array
type Driver ¶
type Driver struct { Driver string `json:"driver" mapstructure:"driver"` User string `json:"user" mapstructure:"user"` Password string `json:"password" mapstructure:"password"` Host string `json:"host" mapstructure:"host"` SSLMode string `json:"ssl_mode" mapstructure:"ssl_mode"` Port string `json:"port" mapstructure:"port"` Name string `json:"name" mapstructure:"name"` // database name DisableLog bool `json:"disable_log" mapstructure:"disable_log"` // disable log Alias string `json:"alias" mapstructure:"alias"` // default set Name value Default bool `json:"default" mapstructure:"default"` // set default }
Driver database driver args struct
type LogWriter ¶
type LogWriter interface {
Println(v ...interface{})
}
LogWriter log writer interface
Click to show internal directories.
Click to hide internal directories.