I have this struct as a go-kallax model:
type Smsgateway struct {
kallax.Model `table:"sms_gateway" pk:"id,autoincr"`
ID int64
Status int
Branch int
Name string
Created_at string
Created_by string
Updated_at string
Updated_by string
Statusname *Status `fk:"ID"`
/*Name1 string
Statusname string
Createdby string*/
}
where status store id of status table and my Status
struct is
type Status struct {
kallax.Model `table:"status" pk:"id,autoincr"`
ID int64
Active int
Updated_by int
Name string
Updated_at string
}
Now if I use go to generate the tables, I can only get Smsgateway table list but not the value of the Name
field from status table. How can I do this?
A little late, but ...
Assuming that the models lie in the module persistence
q := persistence.NewSmsGatewayQuery().WithStatus()
s := persistence.NewSmsGatewayStore(db)
smsGateway, _ := s.FindOne(q)
Now you can access the Name of the Status smsGateway.Status.Name
.
WithStatus() tells kallax to also fetch the related model