diff --git a/templates/05_relationship_to_many.tpl b/templates/05_relationship_to_many.tpl index bad34fd..830eba0 100644 --- a/templates/05_relationship_to_many.tpl +++ b/templates/05_relationship_to_many.tpl @@ -16,12 +16,23 @@ {{- if $isForeignKeySimplyTableName -}} // {{$foreignPluralNoun}} retrieves all the {{$localTableSing}}'s {{$foreignTableHumanReadable}}. -func ({{$receiver}} *{{$localTable}}) {{$foreignPluralNoun}}( +func ({{$receiver}} *{{$localTable}}) {{$foreignPluralNoun}}(selectCols ...string) ({{$foreignSlice}}, error) { + return {{$receiver}}.{{$foreignPluralNoun}}X(boil.GetDB(), selectCols...) +} + +// {{$foreignPluralNoun}} retrieves all the {{$localTableSing}}'s {{$foreignTableHumanReadable}} with an executor. +func ({{$receiver}} *{{$localTable}}) {{$foreignPluralNoun}}X( {{- else -}} {{- $fnName := .ForeignColumn | remove "_id" | titleCase | printf "%[2]s%[1]s" $foreignPluralNoun -}} + // {{$fnName}} retrieves all the {{$localTableSing}}'s {{$foreignTableHumanReadable}} via {{.ForeignColumn}} column. -func ({{$receiver}} *{{$localTable}}) {{$fnName}}( +func ({{$receiver}} *{{$localTable}}) {{$fnName}}(selectCols ...string) ({{$foreignSlice}}, error) { + return {{$receiver}}.{{$fnName}}X(boil.GetDB(), selectCols...) +} + +// {{$fnName}} retrieves all the {{$localTableSing}}'s {{$foreignTableHumanReadable}} via {{.ForeignColumn}} column. +func ({{$receiver}} *{{$localTable}}) {{$fnName}}X( {{- end -}} exec boil.Executor, selectCols ...string) ({{$foreignSlice}}, error) {