Skip to content

Commit

Permalink
读取 ref(pk) 值
Browse files Browse the repository at this point in the history
  • Loading branch information
qida committed Jun 5, 2017
1 parent b4bee5c commit 681fc57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions generate/g_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func Add{{modelName}}(m *{{modelName}}) (id int64, err error) {
func Get{{modelName}}ById(id int64) (v *{{modelName}}, err error) {
o := orm.NewOrm()
v = &{{modelName}}{Id: id}
if err = o.Read(v); err == nil {
if err = o.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil {
return v, nil
}
return nil, err
Expand Down Expand Up @@ -225,7 +225,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
var l []{{modelName}}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {
Expand Down

0 comments on commit 681fc57

Please sign in to comment.