2016-09-18 20:13:11 +02:00
|
|
|
{{- if .Table.IsJoinTable -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $dot := . -}}
|
|
|
|
{{- range .Table.FKeys -}}
|
2016-09-18 20:18:43 +02:00
|
|
|
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}}
|
2016-09-14 10:08:30 +02:00
|
|
|
{{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}}
|
2016-09-18 20:13:11 +02:00
|
|
|
// {{$txt.Function.Name}}G pointed to by the foreign key.
|
|
|
|
func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}G(mods ...qm.QueryMod) {{$varNameSingular}}Query {
|
|
|
|
return {{$txt.Function.Receiver}}.{{$txt.Function.Name}}(boil.GetDB(), mods...)
|
2016-07-17 08:57:08 +02:00
|
|
|
}
|
|
|
|
|
2016-09-18 20:13:11 +02:00
|
|
|
// {{$txt.Function.Name}} pointed to by the foreign key.
|
|
|
|
func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}(exec boil.Executor, mods ...qm.QueryMod) ({{$varNameSingular}}Query) {
|
2016-09-14 10:08:30 +02:00
|
|
|
queryMods := []qm.QueryMod{
|
2016-09-18 20:13:11 +02:00
|
|
|
qm.Where("{{$txt.ForeignTable.ColumnName}}={{if $dot.Dialect.IndexPlaceholders}}$1{{else}}?{{end}}", {{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}),
|
2016-09-14 10:08:30 +02:00
|
|
|
}
|
2016-06-20 01:00:37 +02:00
|
|
|
|
2016-09-14 10:08:30 +02:00
|
|
|
queryMods = append(queryMods, mods...)
|
2016-06-20 01:00:37 +02:00
|
|
|
|
2016-09-18 20:13:11 +02:00
|
|
|
query := {{$txt.ForeignTable.NamePluralGo}}(exec, queryMods...)
|
|
|
|
queries.SetFrom(query.Query, "{{$txt.ForeignTable.Name | $dot.SchemaTable}}")
|
2016-08-06 07:19:49 +02:00
|
|
|
|
2016-09-14 10:08:30 +02:00
|
|
|
return query
|
2016-06-20 01:00:37 +02:00
|
|
|
}
|
2016-08-21 08:28:47 +02:00
|
|
|
{{- end -}}
|
2016-06-20 01:00:37 +02:00
|
|
|
{{- end -}}
|