Add afterSelectHooks to One and All finishers

This commit is contained in:
Patrick O'brien 2016-08-28 22:02:21 +10:00
parent e2553705e1
commit d9ec68b76a

View file

@ -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
}