MCPcopy
hub / github.com/go-gorm/gorm / BeforeSave

Method BeforeSave

tests/hooks_test.go:47–53  ·  view source on GitHub ↗
(tx *gorm.DB)

Source from the content-addressed store, hash-verified

45}
46
47func (s *Product) BeforeSave(tx *gorm.DB) (err error) {
48 if s.Code == "dont_save" {
49 err = errors.New("can't save")
50 }
51 s.BeforeSaveCallTimes = s.BeforeSaveCallTimes + 1
52 return
53}
54
55func (s *Product) AfterFind(tx *gorm.DB) (err error) {
56 s.AfterFindCallTimes = s.AfterFindCallTimes + 1

Callers

nothing calls this directly

Calls 1

NewMethod · 0.65

Tested by

no test coverage detected