美文网首页
beego orm查询数据保存

beego orm查询数据保存

作者: 斯嘎啦 | 来源:发表于2018-09-30 17:21 被阅读0次

beego orm 查询数据库之后,数据需要保存到相应的struct 数组中。 struct 中每个字段需要添加 orm colume(列名), 否则无法给struct中的字段赋值

type EventIgnore struct {
    EventID   string    `json:"event_id" orm:"column(event_id)"`
    StartTime time.Time `json:"start_time" orm:"column(start_time)"`
    EndTime   time.Time `json:"end_time" orm:"column(end_time)"`
}
var ignores []EventIgnore
    _, err := q.Raw("select event_id, start_time,  end_time from event_ignore where end_time<?", t).QueryRows(&ignores)
    fmt.Println(ignores)

相关文章

网友评论

      本文标题:beego orm查询数据保存

      本文链接:https://www.haomeiwen.com/subject/cvgwoftx.html