beego 踩坑集锦

orm 中链式查询问题

//无效
o := orm.NewOrm()
qs := o.QueryTable("comment")
qs.Filter("episodes_id", episodesId)
qs.Filter("status", 1)
qs.OrderBy("-add_time")
qs.Limit(1)
var commentList []Comment
num, err := qs.All(&commentList)
qs := o.QueryTable("comment")
qs = qs.Filter("episodes_id", episodesId)
qs = qs.Filter("status", 1)
qs = qs.OrderBy("-add_time")
qs = qs.Limit(limit, offset)
var commentList []Comment
num, err := qs.Count()
// 或者全部写在一行 否则必须将查询结果重新赋值给qs
_, err = qs.All(&commentList)

你可能感兴趣的:(golang,beego)