fix many to many relationship between users and simulations

This commit is contained in:
Sonja Happ 2019-06-03 14:30:15 +02:00
parent 6e84929ef9
commit 084d3ec8d8

View file

@ -17,10 +17,9 @@ type User struct {
// Role of user // Role of user
Role string `gorm:"default:'user'"` Role string `gorm:"default:'user'"`
// Simulations to which user has access // Simulations to which user has access
Simulations []Simulation `gorm:"many2many:user_simulations"` Simulations []*Simulation `gorm:"many2many:user_simulations"`
} }
// Simulation data model // Simulation data model
type Simulation struct { type Simulation struct {
// ID of simulation // ID of simulation
@ -32,7 +31,7 @@ type Simulation struct {
// Start parameters of simulation as JSON string // Start parameters of simulation as JSON string
StartParameters string StartParameters string
// Users that have access to the simulation // Users that have access to the simulation
Users []User `gorm:"not null;many2many:user_simulations"` Users []*User `gorm:"not null;many2many:user_simulations"`
// Models that belong to the simulation // Models that belong to the simulation
Models []Model `gorm:"foreignkey:SimulationID"` Models []Model `gorm:"foreignkey:SimulationID"`
// Visualizations that belong to the simulation // Visualizations that belong to the simulation
@ -76,7 +75,6 @@ type Signal struct {
Direction string Direction string
} }
// Simulator data model // Simulator data model
type Simulator struct { type Simulator struct {
// ID of the simulator // ID of the simulator
@ -113,7 +111,6 @@ type Visualization struct {
Widgets []Widget `gorm:"foreignkey:VisualizationID"` Widgets []Widget `gorm:"foreignkey:VisualizationID"`
} }
// Widget data model // Widget data model
type Widget struct { type Widget struct {
// ID of widget // ID of widget
@ -146,7 +143,6 @@ type Widget struct {
Files []File `gorm:"foreignkey:WidgetID"` Files []File `gorm:"foreignkey:WidgetID"`
} }
// File data model // File data model
type File struct { type File struct {
// ID of file // ID of file