Documentation ¶
Index ¶
- Variables
- func Create(tx *gorm.DB, Model interface{}, autoCommit bool) error
- func DBInt(model interface{}, o Option, dbObj *gorm.DB) *gorm.DB
- func Delete(tx *gorm.DB, Model interface{}, o Option, Associations []string, ...) error
- func DeleteByID(model interface{}, id uint64) (count int64, err error)
- func DeleteById(tx *gorm.DB, Model interface{}, sqlId interface{}, Associations []string, ...) error
- func DeleteByModel(model interface{}) (count int64, err error)
- func DeleteByWhere(model, where interface{}) (count int64, err error)
- func Error(err error, nullError bool) bool
- func Exist(model interface{}, o Option) (bool, error)
- func Get(db *gorm.DB, Model interface{}, o Option, out interface{}) error
- func GetById(DB *gorm.DB, Model interface{}, sqlId interface{}, out interface{}, ...) error
- func GetResult(dbObj *gorm.DB, o Option, out interface{}) error
- func GetTablePrefix() string
- func InitDB(DBType, DSN string, gdb *gorm.DB)
- func PluckList(model, where interface{}, out interface{}, fieldName string) error
- func Query(db *gorm.DB, Model interface{}, o Option, pageData *response.PageDataList) error
- func Raw(Model interface{}, sql string, o Option, out *[]string) error
- func Save(value interface{}) error
- func Update(tx *gorm.DB, Model interface{}, o Option, data map[string]interface{}, ...) error
- func UpdateById(tx *gorm.DB, Model interface{}, sqlId interface{}, data map[string]interface{}, ...) error
- func UpdateByIdStruct(tx *gorm.DB, Model interface{}, sqlId interface{}, data interface{}, ...) error
- func Updates(where interface{}, value interface{}) error
- type AesStr
- type Association
- type Base
- type BaseByUpdate
- type BaseDeleted
- type BaseDescription
- type BaseID
- type BaseName
- type BaseSql
- type BaseTime
- type Bool
- type ByUpdateDeleted
- type ByUpdateDeletedTime
- type ByUpdateTime
- type BytesUnit
- type DataBases
- type DateTime
- type IdList
- type Int
- type IntArray
- type IntNestArray
- type JSONTime
- type MillisTime
- type Option
- type SecTime
- type StringArray
- type ZhToCode
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
View Source
var DefaultAesKey = "AY3b5Z78806GorMa"
Functions ¶
func DeleteByID ¶
func DeleteById ¶
func DeleteByModel ¶
func DeleteByWhere ¶
func GetTablePrefix ¶
func GetTablePrefix() string
func UpdateById ¶
func UpdateByIdStruct ¶
func UpdateByIdStruct(tx *gorm.DB, Model interface{}, sqlId interface{}, data interface{}, ass []Association, autoCommit bool) error
Types ¶
type AesStr ¶ added in v1.10.2
type AesStr string
type Association ¶
type Association struct { Column string Values interface{} }
type Base ¶
type Base struct { ID int `gorm:"column:id;primary_key;auto_increment;" json:"id" form:"id"` // 主键 Ctime time.Time `gorm:"not null;type:datetime;default:current_timestamp" json:"ctime" form:"ctime"` Mtime time.Time `gorm:"not null;type:datetime;default:current_timestamp on update CURRENT_TIMESTAMP;" json:"mtime" form:"mtime"` }
type BaseByUpdate ¶
type BaseByUpdate struct {
ByUpdate string `gorm:"type:varchar(64);comment:更新人" json:"by_update" form:"by_update"`
}
type BaseDeleted ¶
type BaseDeleted struct {
Deleted bool `gorm:"default:false;comment:标记是否删除;" json:"deleted" form:"deleted"`
}
type BaseDescription ¶
type BaseDescription struct {
ByUpdate string `gorm:"type:varchar(64);comment:更新人" json:"by_update" form:"by_update"`
}
type BaseID ¶
type BaseID struct {
ID int `gorm:"column:id;primary_key;comment:主键id" json:"id" form:"id"` // 主键
}
type BaseName ¶
type BaseName struct {
Name string `gorm:"type:varchar(64);comment:更新人" json:"name" form:"name"`
}
type Bool ¶ added in v1.10.2
type Bool bool
type ByUpdateDeleted ¶
type ByUpdateDeleted struct { BaseByUpdate BaseDeleted }
type ByUpdateDeletedTime ¶
type ByUpdateDeletedTime struct { BaseByUpdate BaseDeleted BaseTime }
type ByUpdateTime ¶
type ByUpdateTime struct { BaseByUpdate BaseTime }
type BytesUnit ¶ added in v1.0.8
type BytesUnit string
type DataBases ¶
type DataBases struct { Engine string `json:"engine" default:"mysql"` Name string `json:"name" default:"ops"` User string `json:"user" default:"root"` Password string `json:"password" default:"123456"` Host string `json:"host" default:"127.0.0.1"` Port string `json:"port" default:"3306"` Charset string `json:"charset" default:"utf8mb4"` Parameters string `json:"parameters"` Options map[string]string `json:"options"` }
type DateTime ¶
DateTime format json time field by myself
func (DateTime) MarshalJSON ¶
MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S
func (*DateTime) UnmarshalJSON ¶ added in v1.0.8
UnmarshalJSON 反序列化
type Int ¶ added in v1.10.2
type Int int
type IntArray ¶ added in v1.0.8
type IntArray []int
type IntNestArray ¶ added in v1.0.8
type IntNestArray [][]int
func (*IntNestArray) Scan ¶ added in v1.0.8
func (j *IntNestArray) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb
type JSONTime ¶
JSONTime format json time field by myself
func (JSONTime) MarshalJSON ¶
MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S
func (*JSONTime) UnmarshalJSON ¶ added in v1.0.8
UnmarshalJSON 反序列化
type MillisTime ¶ added in v1.10.2
type MillisTime string
func (*MillisTime) Scan ¶ added in v1.10.2
func (j *MillisTime) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb
func (*MillisTime) UnmarshalJSON ¶ added in v1.10.2
func (j *MillisTime) UnmarshalJSON(data []byte) error
UnmarshalJSON 反序列化
type Option ¶
type Option struct { DB *gorm.DB Order string Where string Value []interface{} Preloads []string Select string Joins string Group string Having string Distinct []string Scan bool First bool All bool Pluck string Omits []string NullError bool Debug bool Table string }
Option 条件
type SecTime ¶ added in v1.10.2
type SecTime string
func (*SecTime) UnmarshalJSON ¶ added in v1.10.2
UnmarshalJSON 反序列化
type StringArray ¶ added in v1.0.8
type StringArray []string
func (*StringArray) Scan ¶ added in v1.0.8
func (j *StringArray) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb
Click to show internal directories.
Click to hide internal directories.