Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for BeforeDelete (0.07 sec)

  1. schema/callbacks_test.go

    		if !reflect.Indirect(reflect.ValueOf(user)).FieldByName(str).Interface().(bool) {
    			t.Errorf("%v should be true", str)
    		}
    	}
    
    	for _, str := range []string{"BeforeCreate", "BeforeUpdate", "AfterUpdate", "AfterSave", "BeforeDelete", "AfterDelete", "AfterFind"} {
    		if reflect.Indirect(reflect.ValueOf(user)).FieldByName(str).Interface().(bool) {
    			t.Errorf("%v should be false", str)
    		}
    	}
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Jan 06 07:02:53 UTC 2022
    - 939 bytes
    - Viewed (0)
  2. callbacks/delete.go

    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    func BeforeDelete(db *gorm.DB) {
    	if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && db.Statement.Schema.BeforeDelete {
    		callMethod(db, func(value interface{}, tx *gorm.DB) bool {
    			if i, ok := value.(BeforeDeleteInterface); ok {
    				db.AddError(i.BeforeDelete(tx))
    				return true
    			}
    
    			return false
    		})
    	}
    }
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Feb 25 02:48:23 UTC 2022
    - 5.6K bytes
    - Viewed (0)
  3. callbacks/interfaces.go

    }
    
    type BeforeSaveInterface interface {
    	BeforeSave(*gorm.DB) error
    }
    
    type AfterSaveInterface interface {
    	AfterSave(*gorm.DB) error
    }
    
    type BeforeDeleteInterface interface {
    	BeforeDelete(*gorm.DB) error
    }
    
    type AfterDeleteInterface interface {
    	AfterDelete(*gorm.DB) error
    }
    
    type AfterFindInterface interface {
    	AfterFind(*gorm.DB) error
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Aug 27 07:03:57 UTC 2020
    - 667 bytes
    - Viewed (0)
  4. callbacks/callbacks.go

    	deleteCallback := db.Callback().Delete()
    	deleteCallback.Match(enableTransaction).Register("gorm:begin_transaction", BeginTransaction)
    	deleteCallback.Register("gorm:before_delete", BeforeDelete)
    	deleteCallback.Register("gorm:delete_before_associations", DeleteBeforeAssociations)
    	deleteCallback.Register("gorm:delete", Delete(config))
    	deleteCallback.Register("gorm:after_delete", AfterDelete)
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Oct 27 23:56:55 UTC 2021
    - 3.3K bytes
    - Viewed (0)
  5. schema/schema.go

    	callbackTypeAfterUpdate  callbackType = "AfterUpdate"
    	callbackTypeBeforeSave   callbackType = "BeforeSave"
    	callbackTypeAfterSave    callbackType = "AfterSave"
    	callbackTypeBeforeDelete callbackType = "BeforeDelete"
    	callbackTypeAfterDelete  callbackType = "AfterDelete"
    	callbackTypeAfterFind    callbackType = "AfterFind"
    )
    
    // ErrUnsupportedDataType unsupported data type
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Jun 20 12:19:31 UTC 2024
    - 13.7K bytes
    - Viewed (0)
  6. tests/hooks_test.go

    func (s *Product) AfterSave(tx *gorm.DB) (err error) {
    	if s.Code == "after_save_error" {
    		err = errors.New("can't save")
    	}
    	s.AfterSaveCallTimes = s.AfterSaveCallTimes + 1
    	return
    }
    
    func (s *Product) BeforeDelete(tx *gorm.DB) (err error) {
    	if s.Code == "dont_delete" {
    		err = errors.New("can't delete")
    	}
    	s.BeforeDeleteCallTimes = s.BeforeDeleteCallTimes + 1
    	return
    }
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Jun 17 03:59:06 UTC 2024
    - 16.7K bytes
    - Viewed (0)
Back to top