This commit is contained in:
2026-04-18 10:58:00 +03:00
parent 90d027025b
commit 427843f8fc
4 changed files with 62 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type User struct {
@@ -17,7 +18,10 @@ type User struct {
}
func (u *User) AfterCreate(tx *gorm.DB) error {
return tx.FirstOrCreate(&UserSocialRating{}, UserSocialRating{
UserID: u.ID,
}).Error
rating := UserSocialRating{UserID: u.ID}
return tx.
Omit(clause.Associations).
Where("user_id = ?", u.ID).
FirstOrCreate(&rating).Error
}