Documentation ¶
Index ¶
- Variables
- func GenOrm(ormFile string)
- func GetTableFieldNames(args []*ColumnInfo) string
- type Bit
- type ColumnInfo
- type DBInfo
- type GormLogger
- type NullBit
- type NullBool
- type NullFloat64
- type NullInt64
- type NullString
- type NullTime
- type Options
- type SQLExecutor
- type Transaction
- type TransactionObject
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidTimestring = errors.New("msf.db: invalid time string")
ErrInvalidTimestring invalid time string
Functions ¶
func GetTableFieldNames ¶
func GetTableFieldNames(args []*ColumnInfo) string
GetTableFieldNames 根据ColumnInfo 数组返回根据逗号拼接的字段
Types ¶
type Bit ¶
type Bit bool
Bit type
type ColumnInfo ¶
type ColumnInfo struct { Field string Type string Null string Key string Default *string Extra string AutoIncrement bool Unique bool GoType string }
ColumnInfo table column info
type DBInfo ¶
DBInfo db链接信息
func (*DBInfo) Begin ¶
func (dbInfo *DBInfo) Begin(trans *Transaction, objects ...TransactionObject) (*Transaction, error)
Begin 开启事物
type NullBit ¶
NullBit null bit
func (NullBit) MarshalJSON ¶
MarshalJSON correctly serializes a NullString to JSON
func (*NullBit) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a NullString from JSON
type NullBool ¶
NullBool is a type that can be null or a bool
func (NullBool) MarshalJSON ¶
MarshalJSON correctly serializes a NullBool to JSON
func (*NullBool) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a NullBool from JSON
type NullFloat64 ¶
type NullFloat64 struct {
sql.NullFloat64
}
NullFloat64 is a type that can be null or a float64
func (NullFloat64) MarshalJSON ¶
func (n NullFloat64) MarshalJSON() ([]byte, error)
MarshalJSON correctly serializes a NullFloat64 to JSON
func (*NullFloat64) UnmarshalJSON ¶
func (n *NullFloat64) UnmarshalJSON(b []byte) error
UnmarshalJSON correctly deserializes a NullFloat64 from JSON
type NullInt64 ¶
NullInt64 is a type that can be null or an int
func (NullInt64) MarshalJSON ¶
MarshalJSON correctly serializes a NullInt64 to JSON
func (*NullInt64) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a NullInt64 from JSON
type NullString ¶
type NullString struct {
sql.NullString
}
NullString is a type that can be null or a string
func (NullString) MarshalJSON ¶
func (n NullString) MarshalJSON() ([]byte, error)
MarshalJSON correctly serializes a NullString to JSON
func (*NullString) UnmarshalJSON ¶
func (n *NullString) UnmarshalJSON(b []byte) error
UnmarshalJSON correctly deserializes a NullString from JSON
type NullTime ¶
NullTime is a type that can be null or a time
func (NullTime) MarshalJSON ¶
MarshalJSON correctly serializes a NullTime to JSON
func (*NullTime) Scan ¶
Scan implements the Scanner interface. The value type must be time.Time or string / []byte (formatted time-string), otherwise Scan fails.
func (*NullTime) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a NullTime from JSON
type Options ¶
type Options struct { Driver string `json:"driver"` Host string `json:"host"` DBName string `json:"dbName"` Username string `json:"username"` Password string `json:"password"` DataSource string `json:"dataSource"` EnableLog bool `json:"enable_log"` LogLevel int `json:"logLevel"` MaxIdleConns int `json:"maxIdleConns"` MaxOpenConns int `json:"maxOpenConns"` }
Options 数据库配置
type SQLExecutor ¶
type SQLExecutor interface { NewRecord(value interface{}) bool Create(value interface{}) *gorm.DB Save(value interface{}) *gorm.DB Delete(value interface{}, where ...interface{}) *gorm.DB Find(out interface{}, where ...interface{}) *gorm.DB Exec(sql string, values ...interface{}) *gorm.DB First(out interface{}, where ...interface{}) *gorm.DB }
SQLExecutor sql执行器
type Transaction ¶
Transaction 事物维护的object
func (*Transaction) AddObject ¶
func (trans *Transaction) AddObject(o TransactionObject)
AddObject 往事物维护的object中增加object
type TransactionObject ¶
type TransactionObject interface {
SetTransaction(trans *Transaction)
}
TransactionObject interface