Skip to content

Commit

Permalink
Merge pull request #1202 from cubiest/features/exists
Browse files Browse the repository at this point in the history
Small Change: Allow calling struct.Exists() without having to pass on PK fields
  • Loading branch information
stephenafamo committed Sep 26, 2022
2 parents 92bf892 + ca4aba1 commit f6f4805
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions templates/main/20_exists.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ func {{$alias.UpSingular}}Exists({{if .NoContext}}exec boil.Executor{{else}}ctx
return exists, nil
}

// Exists checks if the {{$alias.UpSingular}} row exists.
func (o *{{$alias.UpSingular}}) Exists({{if .NoContext}}exec boil.Executor{{else}}ctx context.Context, exec boil.ContextExecutor{{end}}) (bool, error) {
return {{$alias.UpSingular}}Exists({{if .NoContext}}exec{{else}}ctx, exec{{end}}, o.{{$.Table.PKey.Columns | stringMap (aliasCols $alias) | join ", o."}})
}

{{- end -}}

0 comments on commit f6f4805

Please sign in to comment.