You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set up a many-to-many relationship in Go Admin, specifically between a Guide model and a Region model:
type Region struct {
gorm.Model
Name string `gorm:"type:varchar(100)"`
}
type Guide struct {
gorm.Model
Name string `gorm:"type:varchar(100)"`
Regions []Region `gorm:"many2many:guide_regions;"`
}
'm having trouble figuring out how to properly handle this relationship in the table setup, particularly for create, update, and delete operations.
My main questions are:
How do I properly save the selected relations when creating or updating a Guide?
How do I ensure that the related records in the junction table (guide_regions) are deleted when a Guide is deleted?
Description [describe your questions]
I'm trying to set up a many-to-many relationship in Go Admin, specifically between a Guide model and a Region model:
'm having trouble figuring out how to properly handle this relationship in the table setup, particularly for create, update, and delete operations.
My main questions are:
How do I properly save the selected relations when creating or updating a Guide?
How do I ensure that the related records in the junction table (guide_regions) are deleted when a Guide is deleted?
Example code [If you have any code info]
func GetGuidesTable(ctx *context.Context) table.Table {
guides := table.NewDefaultTable(ctx, table.DefaultConfigWithDriver("postgresql"))
}
Thanks!
The text was updated successfully, but these errors were encountered: