gen
gen copied to clipboard
Add embedded structs on generate
I want to generate all models from my database tables, using g.GenerateAllTable()...,, but I'd like for it to add all of the embedded fields too.
For example, with a struct like User:
type Users struct {
ID string `gorm:"column:id;primaryKey" json:"id"`
EffectiveDate time.Time `gorm:"column:effective_date" json:"effective_date"`
ExpirationDate time.Time `gorm:"column:expiration_date" json:"expiration_date"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
Email string `gorm:"column:email" json:"email"`
OrganizationID string `gorm:"column:organization_id" json:"organization_id"`
Onboarded bool `gorm:"column:onboarded" json:"onboarded"`
}
Is there a way to automatically add the Organization field of type Organization without specifically specifying?
Thought it should be explained here here
How can I achieve this without specifying the relationships for each model?
I am looking for the same thing