请问有谁知道如何在水牛模型中指定多对多关系?
gobuffalo many_to_many ...
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"`
}
这些结构中的每一个都在自己的模型中/*.go 文件中
https://gobuffalo.io/en/docs/db/relations