fix broken create
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel 2024-05-23 13:55:05 +03:00
parent 2cd46585a8
commit be2cc7ddfa
3 changed files with 9 additions and 0 deletions

View File

@ -47,6 +47,9 @@ func (c *Chat) ByIDWithIntegrations(id uint64) (*model.Chat, error) {
} }
func (c *Chat) Save(chat *model.Chat) error { func (c *Chat) Save(chat *model.Chat) error {
if chat.ID == 0 {
return c.db.Create(chat).Error
}
return c.db.Model(chat).Save(chat).Error return c.db.Model(chat).Save(chat).Error
} }

View File

@ -23,6 +23,9 @@ func (r *Integration) LoadForChatAndType(chatID uint64, typ model.IntegrationTyp
} }
func (r *Integration) Save(integration *model.Integration) error { func (r *Integration) Save(integration *model.Integration) error {
if integration.ID == 0 {
return r.db.Create(integration).Error
}
return r.db.Model(integration).Save(integration).Error return r.db.Model(integration).Save(integration).Error
} }

View File

@ -47,5 +47,8 @@ func (u *User) ByIDWithChats(id uint64) (*model.User, error) {
} }
func (u *User) Save(user *model.User) error { func (u *User) Save(user *model.User) error {
if user.ID == 0 {
return u.db.Create(user).Error
}
return u.db.Model(user).Save(user).Error return u.db.Model(user).Save(user).Error
} }