GORM itself is powered by Callbacks
, so you could fully customize GORM as you want
Register a new callback
Register a callback into callbacks
func updateCreated(scope *Scope) { |
Delete an existing callback
Delete a callback from callbacks
db.Callback().Create().Remove("gorm:create") |
Replace an existing callback
Replace a callback having same name with new one
db.Callback().Create().Replace("gorm:create", newCreateFunction) |
Register callback orders
Register callbacks with orders
db.Callback().Create().Before("gorm:create").Register("update_created_at", updateCreated) |
Pre-Defined Callbacks
GORM has defiend callbacks to perform CRUD operations, check them out before start write your plugins
Row Query callbacks - no callbacks registered by default
Row Query callbacks will be called when perform Row
or Rows
, there are no registered callbacks by default, you could register a new one like:
func updateTableName(scope *gorm.Scope) { |
View https://godoc.org/github.com/jinzhu/gorm to view all available API