mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Associations autoupdate OFF. Formated model structs.
This commit is contained in:
parent
3682ae265a
commit
9df906bc15
2 changed files with 54 additions and 40 deletions
|
@ -138,13 +138,13 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
|||
test_db.Model(&simn_A).Association("Projects").Append(&proj_B)
|
||||
|
||||
test_db.Model(&proj_A).Association("Simulation").Append(&simn_A)
|
||||
test_db.Debug().Model(&proj_A).Association("User").Append(&usr_A)
|
||||
test_db.Model(&proj_A).Association("User").Append(&usr_A)
|
||||
test_db.Model(&proj_A).Association("Visualizations").Append(&vis_A)
|
||||
test_db.Model(&proj_A).Association("Visualizations").Append(&vis_B)
|
||||
|
||||
test_db.Model(&usr_A).Association("Projects").Append(&proj_A)
|
||||
test_db.Model(&usr_A).Association("Projects").Append(&proj_B)
|
||||
test_db.Debug().Model(&usr_A).Association("Simulations").Append(&simn_A)
|
||||
test_db.Model(&usr_A).Association("Simulations").Append(&simn_A)
|
||||
test_db.Model(&usr_A).Association("Simulations").Append(&simn_B)
|
||||
test_db.Model(&usr_A).Association("Files").Append(&file_A)
|
||||
test_db.Model(&usr_A).Association("Files").Append(&file_B)
|
||||
|
|
|
@ -26,30 +26,36 @@ type File struct {
|
|||
Size uint `gorm:"not null"`
|
||||
ImageHeight uint // only required in case file is an image
|
||||
ImageWidth uint // only required in case file is an image
|
||||
User User `gorm:"not null"`
|
||||
UserID uint `gorm:"not null"`
|
||||
Date time.Time
|
||||
|
||||
User User `gorm:"not null;association_autoupdate:false"`
|
||||
UserID uint `gorm:"not null"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"not null"`
|
||||
User User `gorm:"not null"`
|
||||
|
||||
User User `gorm:"not null;association_autoupdate:false"`
|
||||
UserID uint `gorm:"not null"`
|
||||
Simulation Simulation `gorm:"not null"`
|
||||
|
||||
Simulation Simulation `gorm:"not null;association_autoupdate:false"`
|
||||
SimulationID uint `gorm:"not null"`
|
||||
Visualizations []Visualization
|
||||
|
||||
Visualizations []Visualization `gorm:"association_autoupdate:false"`
|
||||
}
|
||||
|
||||
type Simulation struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"not null"`
|
||||
Running bool `gorm:"default:false"`
|
||||
User User `gorm:"not null"`
|
||||
UserID uint `gorm:"not null"`
|
||||
StartParameters postgres.Jsonb // TODO default value
|
||||
Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID"`
|
||||
Projects []Project
|
||||
|
||||
User User `gorm:"not null;association_autoupdate:false"`
|
||||
UserID uint `gorm:"not null"`
|
||||
|
||||
Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID;association_autoupdate:false"`
|
||||
Projects []Project `gorm:"association_autoupdate:false"`
|
||||
}
|
||||
|
||||
type SimulationModel struct {
|
||||
|
@ -57,13 +63,17 @@ type SimulationModel struct {
|
|||
Name string `gorm:"not null"`
|
||||
OutputLength int `gorm:"default:1"`
|
||||
InputLength int `gorm:"default:1"`
|
||||
OutputMapping []Signal // order of signals is important
|
||||
InputMapping []Signal // order of signals is important
|
||||
StartParameters postgres.Jsonb // TODO: default value?
|
||||
BelongsToSimulation Simulation `gorm:"not null"`
|
||||
|
||||
BelongsToSimulation Simulation `gorm:"not null;association_autoupdate:false"`
|
||||
BelongsToSimulationID uint `gorm:"not null"`
|
||||
BelongsToSimulator Simulator `gorm:"not null"`
|
||||
|
||||
BelongsToSimulator Simulator `gorm:"not null;association_autoupdate:false"`
|
||||
BelongsToSimulatorID uint `gorm:"not null"`
|
||||
|
||||
// NOTE: order of signals is important
|
||||
OutputMapping []Signal `gorm:"association_autoupdate:false"`
|
||||
InputMapping []Signal `gorm:"association_autoupdate:false"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
|
@ -72,20 +82,24 @@ type User struct {
|
|||
Password string `gorm:"not null"`
|
||||
Mail string `gorm:"default:''"`
|
||||
Role string `gorm:"default:'user'"`
|
||||
Projects []Project
|
||||
Simulations []Simulation
|
||||
Files []File
|
||||
|
||||
Projects []Project `gorm:"association_autoupdate:false"`
|
||||
Simulations []Simulation `gorm:"association_autoupdate:false"`
|
||||
Files []File `gorm:"association_autoupdate:false"`
|
||||
}
|
||||
|
||||
type Visualization struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"not null"`
|
||||
Project Project `gorm:"not null"`
|
||||
ProjectID uint `gorm:"not null"`
|
||||
Grid int `gorm:"default:15"`
|
||||
User User `gorm:"not null"`
|
||||
|
||||
Project Project `gorm:"not null;association_autoupdate:false"`
|
||||
ProjectID uint `gorm:"not null"`
|
||||
|
||||
User User `gorm:"not null;association_autoupdate:false"`
|
||||
UserID uint `gorm:"not null"`
|
||||
Widgets []Widget
|
||||
|
||||
Widgets []Widget `gorm:"association_autoupdate:false"`
|
||||
}
|
||||
|
||||
type Signal struct {
|
||||
|
|
Loading…
Add table
Reference in a new issue