1 回答
TA贡献2016条经验 获得超9个赞
戈布法罗多对多 ...
type Organization struct {
ID int `json:"id" db:"id"`
Users Users `many_to_many:"user_organizations"`
}
type User struct {
ID int `json:"id" db:"id"`
Organizations Organizations `many_to_many:"user_organizations" json:"-"`
}
type UserOrganization struct {
ID int `json:"id" db:"id"`
OrganizationID int `json:"organization_id" db:"organization_id"`
UserID int `json:"user_id" db:"user_id"`
User User `belongs_to:"users"`
Organization Organization `belongs_to:"organizations"`
}
每个结构都在自己的 models/*.go 文件中
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报