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