Documentation ¶
Index ¶
- Variables
- func Delete(where ...interface{}) (result sql.Result, err error)
- func FindArray(fieldsAndWhere ...interface{}) ([]gdb.Value, error)
- func FindCount(where ...interface{}) (int, error)
- func FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error)
- func Insert(data ...interface{}) (result sql.Result, err error)
- func InsertIgnore(data ...interface{}) (result sql.Result, err error)
- func Replace(data ...interface{}) (result sql.Result, err error)
- func Save(data ...interface{}) (result sql.Result, err error)
- func Update(dataAndWhere ...interface{}) (result sql.Result, err error)
- type Entity
- func (r *Entity) Delete() (result sql.Result, err error)
- func (r *Entity) Insert() (result sql.Result, err error)
- func (r *Entity) InsertIgnore() (result sql.Result, err error)
- func (r *Entity) OmitEmpty() *arModel
- func (r *Entity) Replace() (result sql.Result, err error)
- func (r *Entity) Save() (result sql.Result, err error)
- func (r *Entity) Update() (result sql.Result, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // Table is the table name of gf_article. Table = "gf_article" // Model is the model object of gf_article. Model = &arModel{g.DB("default").Table(Table).Safe()} // Columns defines and stores column names for table gf_article. Columns = struct { Id string // Key string // 文章唯一键名,用于程序硬编码使用 Cid string // 栏目ID Uid string // 用户ID Title string // 标题 Content string // 内容 Sort string // 排序,数值越低越靠前,默认为添加时的时间戳,可用于置顶 Brief string // 摘要 Thumb string // 缩略图 Tags string // 标签名称列表(以#号分割) Referer string // 内容来源 Status string // 状态\n0: 禁用\n1: 正常 Zan string // 赞 Cai string // 踩 CreateAt string // 创建时间 UpdateAt string // 修改时间 }{ Id: "id", Key: "key", Cid: "cid", Uid: "uid", Title: "title", Content: "content", Sort: "sort", Brief: "brief", Thumb: "thumb", Tags: "tags", Referer: "referer", Status: "status", Zan: "zan", Cai: "cai", CreateAt: "create_at", UpdateAt: "update_at", } )
Functions ¶
func InsertIgnore ¶
InsertIgnore is a convenience method for Model.InsertIgnore.
Types ¶
type Entity ¶
type Entity struct { Id uint `orm:"id,primary" json:"id"` // Key string `orm:"key" json:"key"` // 文章唯一键名,用于程序硬编码使用 Cid uint `orm:"cid" json:"cid"` // 栏目ID Uid uint `orm:"uid" json:"uid"` // 用户ID Title string `orm:"title" json:"title"` // 标题 Content string `orm:"content" json:"content"` // 内容 Sort uint `orm:"sort" json:"sort"` // 排序,数值越低越靠前,默认为添加时的时间戳,可用于置顶 Brief string `orm:"brief" json:"brief"` // 摘要 Thumb string `orm:"thumb" json:"thumb"` // 缩略图 Tags string `orm:"tags" json:"tags"` // 标签名称列表(以#号分割) Referer string `orm:"referer" json:"referer"` // 内容来源 Status uint `orm:"status" json:"status"` // 状态\n0: 禁用\n1: 正常 Zan uint `orm:"zan" json:"zan"` // 赞 Cai uint `orm:"cai" json:"cai"` // 踩 CreateAt *gtime.Time `orm:"create_at" json:"create_at"` // 创建时间 UpdateAt *gtime.Time `orm:"update_at" json:"update_at"` // 修改时间 }
Entity is the golang structure for table gf_article.
func (*Entity) Delete ¶
Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
func (*Entity) Insert ¶
Inserts does "INSERT...INTO..." statement for inserting current object into table.
func (*Entity) InsertIgnore ¶
InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
func (*Entity) OmitEmpty ¶
func (r *Entity) OmitEmpty() *arModel
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*Entity) Replace ¶
Replace does "REPLACE...INTO..." statement for inserting current object into table. If there's already another same record in the table (it checks using primary key or unique index), it deletes it and insert this one.