diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-05-13 16:52:04 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-05-13 16:52:04 +0200 |
| commit | 61c7bf4567249da0d13c2f738e56754a2c181c99 (patch) | |
| tree | 2a4f52d3c3e0b3d6f381882392743d07f65bbb5b /user/member.go | |
| parent | 01bafe9bf1de5be4e770b9500480807d4973d8d6 (diff) | |
fix(db): wrong relation and bad where condition
Diffstat (limited to 'user/member.go')
| -rw-r--r-- | user/member.go | 16 |
1 files changed, 8 insertions, 8 deletions
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 } |
