diff options
Diffstat (limited to 'item/hooks.go')
-rw-r--r-- | item/hooks.go | 13 |
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 } |