**
beego orm设置模型关系的约束的时候 什么时候使用rel 什么时候reverse RT
**
官方例子 设置关系字段有 rel 和reverse 这两个值,怎么决定建立关系的时候用反射 还是直接用
`type User struct {
Id int
Name string
Profile *Profile `orm:"rel(one)"` // OneToOne relation
Post []*Post `orm:"reverse(many)"` // 设置一对多的反向关系
}
type Profile struct {
Id int
Age int16
User *User `orm:"reverse(one)"` // 设置一对一反向关系(可选)
}
type Post struct {
Id int
Title string
User *User `orm:"rel(fk)"` //设置一对多关系
Tags []*Tag `orm:"rel(m2m)"`
}
3501

被折叠的 条评论
为什么被折叠?



