parent
ca9f47de8b
commit
ce9d13abf0
1 changed files with 3 additions and 2 deletions
|
@ -956,15 +956,16 @@ it with the `AddModelHook` method. Here is an example of a before insert hook:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Define my hook function
|
// Define my hook function
|
||||||
func myHook(exec boil.Executor, p *Pilot) {
|
func myHook(exec boil.Executor, p *Pilot) error {
|
||||||
// Do stuff
|
// Do stuff
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register my before insert hook for pilots
|
// Register my before insert hook for pilots
|
||||||
models.AddPilotHook(boil.BeforeInsertHook, myHook)
|
models.AddPilotHook(boil.BeforeInsertHook, myHook)
|
||||||
```
|
```
|
||||||
|
|
||||||
Your `ModelHook` will always be defined as `func(boil.Executor, *Model)`
|
Your `ModelHook` will always be defined as `func(boil.Executor, *Model) error`
|
||||||
|
|
||||||
### Transactions
|
### Transactions
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue