I have these two structures:
type Collection struct {
gorm.Model
APIKey string
CollectionID string
Name string
Environments []Environment
}
type Environment struct {
gorm.Model
EnvironmentID string
Name string
Provider string
FlightType string
ADT int
CHD int
INF int
}
And the main looks like:
func main() {
adminResource := admin.New(&admin.AdminConfig{DB: model.DB})
adminResource.AddResource(&model.Collection{})
adminResource.AddResource(&model.Environment{})
mux := http.NewServeMux()
adminResource.MountTo("/admin", mux)
if err := http.ListenAndServe(":8000", mux); err != nil {
panic(err)
} else {
fmt.Println("Listening on: 8000")
}
}
The point is that I don´t know if I should to do something else to allow the membership relationship one-to-many between the Collection and the Environemt. The thing is that the form on the admin view looks good, I can add as many environments as I was... but submitting the form only the Collection
are saved on the database.