From 4281d32974ed523d2d7cdbfb1813abda8bca8b2e Mon Sep 17 00:00:00 2001 From: iChemy Date: Thu, 19 Dec 2024 13:48:51 +0900 Subject: [PATCH] :zap: Room's BeforeUpdate hook --- infra/db/hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/db/hooks.go b/infra/db/hooks.go index 3c7f6ff..6e174fd 100644 --- a/infra/db/hooks.go +++ b/infra/db/hooks.go @@ -180,7 +180,7 @@ func (r *Room) BeforeSave(tx *gorm.DB) (err error) { } func (r *Room) BeforeUpdate(tx *gorm.DB) (err error) { - if err := tx.Model(r).Association("Admins").Clear(); err != nil { + if err := tx.Model(&Room{ID: r.ID}).Association("Admins").Clear(); err != nil { return err } return nil