Skip to content

Commit

Permalink
Add gorm config to save all associations
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Apr 14, 2023
1 parent 4889ff3 commit 4404564
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/turing/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func InitDB(cfg *config.DatabaseConfig) (*gorm.DB, error) {
db, err := gorm.Open(
pg.Open(connectionString(cfg)),
&gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
// This is needed to ensure that any saves to nested fields also update their respective tables
FullSaveAssociations: true,
Logger: logger.Default.LogMode(logger.Silent),
},
)
if err != nil {
Expand Down

0 comments on commit 4404564

Please sign in to comment.