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

Method BeforeCreate

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

Source from the content-addressed store, hash-verified

29}
30
31func (s *Product) BeforeCreate(tx *gorm.DB) (err error) {
32 if s.Code == "Invalid" {
33 err = errors.New("invalid product")
34 }
35 s.BeforeCreateCallTimes = s.BeforeCreateCallTimes + 1
36 return
37}
38
39func (s *Product) BeforeUpdate(tx *gorm.DB) (err error) {
40 if s.Code == "dont_update" {

Callers

nothing calls this directly

Calls 1

NewMethod · 0.65

Tested by

no test coverage detected