beego 如何获取foreign key字段?

新手上路,请多包涵
type Article struct {
    Id    int64
    Title string
    Content    string `orm:"size(5000)"`
    Author     string
    Source     string
    Keywords   string
    Overview   string
    Attachment string
    Created    time.Time `orm:"index"`
    Updated    time.Time `orm:"index"`
    Type       int64
    Category   *Category `orm:"rel(fk)"`
}

type Category struct {
    Id      int64
    Name    string
    Created time.Time `orm:"index"`
    Updated time.Time `orm:"index"`
}

各位大神们怎么搞啊?
如图beego orm增加表关系,article 的 foreign key为category。这样会在article表里自动增加一个category_id的字段。那么问题来了,比如我想修改这个article表里的category_id的字段的值,改怎么该?怎么才能获取这个category_id字段啊? 比如其他字段都是article.Title article.Author等。

阅读 4.1k
1 个回答

描述的不清楚

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题