GORM は Callbacks
によってフルカスタマイズすることができます
新たに callback を登録します
Register a callback into callbacks
func updateCreated(scope *Scope) { |
callback を削除します
Delete a callback from callbacks
db.Callback().Create().Remove("gorm:create") |
callback を置き換えます
Replace a callback having same name with new one
db.Callback().Create().Replace("gorm:create", newCreateFunction) |
順序付きで callback を登録します
Register callbacks with orders
db.Callback().Create().Before("gorm:create").Register("update_created_at", updateCreated) |
定義済みの Callback
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