type selectUserWithOrders struct {
id int
name string
orders []order
}
type order struct {
id int
total int
}
// user table columns are -> id , name, password
// orders table columns are -> id, user_id(fk), order_value
func (r *Repository) SelectOne(
id int,
) (selectUserWithOrders, bool, error) {
var user selectUserWithOrders
exists, err := r.goquDB.From(
TABLE,
).Select(
).Where(goqu.C(ID).Eq(id)).ScanStruct(&user)
if err != nil {
return selectUserWithOrders{}, false, err
}
return user, exists, nil
}
i am trying to do join on user and order table using user id
I am unable to find solution to do this in single query or or without use of loop