Open newerton opened 5 years ago
Hello qiangxue, miss you on the Yii team.
I'm diversifying my portfolio, and improving my clients' APIs, I'm learning Go lang.
I followed several tutorials and blog about relationship, and I am 3 days without being able to make a BELONGS TO relationship.
What am I doing wrong, can you help me?
daos/product.go
func (dao *ProductDAO) Query(rs app.RequestScope, offset, limit int) ([]models.Product, error) { products := []models.Product{} err := rs.Tx().Select(). InnerJoin("establishment", dbx.NewExp("`product`.`establishment_id` = `establishment`.`id`")). OrderBy("product.id"). Offset(int64(offset)). Limit(int64(limit)). All(&products) return products, err }
models/product.go
type Product struct { Id int `json:"id" db:"id"` Establishment Establishment `json:"establishment" db:"establishment"` }
models/establishment.go
type Establishment struct { Id int `json:"id" db:"id"` Subtitle string `json:"subtitle" db:"subtitle"` }
Hello qiangxue, miss you on the Yii team.
I'm diversifying my portfolio, and improving my clients' APIs, I'm learning Go lang.
I followed several tutorials and blog about relationship, and I am 3 days without being able to make a BELONGS TO relationship.
What am I doing wrong, can you help me?
daos/product.go
models/product.go
models/establishment.go