gorm/callbacks/callbacks.go

13 lines
471 B
Go
Raw Normal View History

2020-02-02 03:35:01 +03:00
package callbacks
import "github.com/jinzhu/gorm"
func RegisterDefaultCallbacks(db *gorm.DB) {
callback := db.Callback()
callback.Create().Register("gorm:before_create", BeforeCreate)
callback.Create().Register("gorm:save_before_associations", SaveBeforeAssociations)
callback.Create().Register("gorm:create", Create)
callback.Create().Register("gorm:save_after_associations", SaveAfterAssociations)
callback.Create().Register("gorm:after_create", AfterCreate)
}