From 61c7bf4567249da0d13c2f738e56754a2c181c99 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 16:52:04 +0200 Subject: fix(db): wrong relation and bad where condition --- user/member.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'user/member.go') diff --git a/user/member.go b/user/member.go index cf7c4a4..71a369b 100644 --- a/user/member.go +++ b/user/member.go @@ -8,16 +8,16 @@ import ( ) type Copaing struct { - ID uint `gorm:"primarykey"` - DiscordID string `gorm:"not null"` - XP []CopaingXP `gorm:"constraint:OnDelete:SET NULL;"` - GuildID string `gorm:"not null"` + ID uint `gorm:"primarykey"` + DiscordID string `gorm:"not null"` + CopaingXPs []CopaingXP `gorm:"constraint:OnDelete:SET NULL;"` + GuildID string `gorm:"not null"` } type CopaingXP struct { - ID uint `gorm:"primarykey"` - XP uint `gorm:"default:0"` - CopaingID uint `gorm:"not null;constraint:OnDelete:CASCADE;"` + ID uint `gorm:"primarykey"` + XP uint `gorm:"default:0"` + CopaingID uint GuildID string `gorm:"not null;"` CreatedAt time.Time } @@ -51,7 +51,7 @@ func GetCopaing(discordID string, guildID string) *Copaing { func (c *Copaing) Load() error { return gokord.DB. Where("discord_id = ? and guild_id = ?", c.DiscordID, c.GuildID). - Preload("XP"). + Preload("CopaingXPs"). FirstOrCreate(c). Error } -- cgit v1.2.3