-
-
Notifications
You must be signed in to change notification settings - Fork 415
Closed
Labels
Description
I want to use "has-one" relation. Example;
type UserDB struct {
ID int `json:"-"
UserID string `json:"userID" pg:",unique"`
// Other user fields
}
type UserDetailDB struct {
ID int `json:"-" `
UserID string `json:"userID" pg:",unique"`
UserDB *UserDB `json:"user,omitempty" pg:"rel:has-one,fk:user_id,join_fk:user_id"`
// Other User Detail fields
}
var userDetailDB []UserDetailDB
db.Model(&userDetailDB).Column("user_detail_db.*").Relation("UserDB") ....
When I do this, it creates a query like
LEFT JOIN" user_dbs "AS" user_db "ON" user_db "." Id "=" user_detail_db "." User_id "
While "user_detail_db" gets "user_id" as I want, "user_db" gets "id". I want "user_id" in both tables.
What can I do ?
mojtabacazi