Add afterSelectHooks to One and All finishers
This commit is contained in:
parent
e2553705e1
commit
d9ec68b76a
1 changed files with 16 additions and 0 deletions
|
@ -24,6 +24,12 @@ func (q {{$varNameSingular}}Query) One() (*{{$tableNameSingular}}, error) {
|
|||
return nil, errors.Wrap(err, "{{.PkgName}}: failed to execute a one query for {{.Table.Name}}")
|
||||
}
|
||||
|
||||
{{if eq .NoHooks false -}}
|
||||
if err := o.doAfterSelectHooks(); err != nil {
|
||||
return o, err
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
return o, nil
|
||||
}
|
||||
|
||||
|
@ -46,6 +52,16 @@ func (q {{$varNameSingular}}Query) All() ({{$tableNameSingular}}Slice, error) {
|
|||
return nil, errors.Wrap(err, "{{.PkgName}}: failed to assign all query results to {{$tableNameSingular}} slice")
|
||||
}
|
||||
|
||||
{{if eq .NoHooks false -}}
|
||||
if len({{$varNameSingular}}AfterSelectHooks) != 0 {
|
||||
for _, obj := range o {
|
||||
if err := obj.doAfterSelectHooks(); err != nil {
|
||||
return o, err
|
||||
}
|
||||
}
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
return o, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue