allow updating tags of items

This commit is contained in:
2025-03-03 17:49:38 +01:00
parent 07ee8a004c
commit 1dc10d61bc
2 changed files with 16 additions and 0 deletions

View File

@@ -69,6 +69,11 @@ func (r *GORMShopItemRepository) GetById(id string) (models.ShopItem, error) {
}
func (r *GORMShopItemRepository) Update(shopItem models.ShopItem) (models.ShopItem, error) {
err := r.DB.Model(&shopItem).Association("Tags").Replace(shopItem.Tags)
if err != nil {
return models.ShopItem{}, err
}
result := r.DB.Save(&shopItem)
if result.Error != nil {
return models.ShopItem{}, result.Error