save record with associations
Marco Andronaco andronacomarco@gmail.com
Sun, 06 Oct 2024 14:59:45 +0200
1 files changed,
2 insertions(+),
1 deletions(-)
jump to
M
src/api/api.go
→
src/api/api.go
@@ -6,6 +6,7 @@ "log"
"net/http" "github.com/BiRabittoh/piggy/src/app" + "gorm.io/gorm" ) func getBookmakers(w http.ResponseWriter, r *http.Request) {@@ -172,7 +173,7 @@ log.Println("could not decode record JSON: " + err.Error())
new400Error(w, err) return } - err = app.DB.Save(&record).Error + err = app.DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&record).Error if err != nil { log.Println("could not save record: " + err.Error()) new500Error(w, err)