aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/item/hooks.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-10-11 20:55:48 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-10-11 20:55:48 +0530
commitbc154857fb5569d7c1fa9785cc891cb927a6a156 (patch)
tree590c9f6a00a1b97b2ee45cfa5a767558089affe0 /item/hooks.go
parent8a47978ca17d2f251d67d12b0e34fa26bb1e4ace (diff)
removed per-user itemsv0.17.0
Diffstat (limited to 'item/hooks.go')
-rw-r--r--item/hooks.go13
1 files changed, 1 insertions, 12 deletions
diff --git a/item/hooks.go b/item/hooks.go
index 74b6860..5056cb1 100644
--- a/item/hooks.go
+++ b/item/hooks.go
@@ -20,22 +20,11 @@ package item
import (
"gorm.io/gorm"
"vidhukant.com/openbills/errors"
- e "errors"
)
func (i *SavedItem) BeforeSave(tx *gorm.DB) error {
var err error
- // also checks if brand actually exists
- err = checkBrandOwnership(i.BrandID, i.UserID)
- if err != nil {
- if e.Is(err, errors.ErrBrandNotFound) {
- // this error has a better error message for this case
- return errors.ErrBrandNotFound
- }
- return err
- }
-
err = i.validate()
if err != nil {
return err
@@ -60,7 +49,7 @@ func (b *Brand) BeforeDelete(tx *gorm.DB) error {
}
// delete all items
- err := db.Where("brand_id = ? and user_id = ?", b.ID, b.UserID).Delete(&SavedItem{}).Error
+ err := db.Where("brand_id = ?", b.ID).Delete(&SavedItem{}).Error
if err != nil {
return err
}