2016-09-19 01:26:30 +02:00
|
|
|
{{- if .Table.IsJoinTable -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $dot := . -}}
|
2016-09-19 01:49:18 +02:00
|
|
|
{{- range .Table.ToOneRelationships -}}
|
|
|
|
{{- $txt := txtsFromOneToOne $dot.Tables $dot.Table . -}}
|
2017-05-09 21:30:04 +02:00
|
|
|
{{- $tableNameSingular := .ForeignTable | singular | titleCase}}
|
2016-09-19 01:26:30 +02:00
|
|
|
// {{$txt.Function.Name}}G pointed to by the foreign key.
|
2017-05-09 21:30:04 +02:00
|
|
|
func (o *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}G(mods ...qm.QueryMod) {{$tableNameSingular}}Query {
|
2016-09-21 05:37:28 +02:00
|
|
|
return o.{{$txt.Function.Name}}(boil.GetDB(), mods...)
|
2016-09-19 01:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// {{$txt.Function.Name}} pointed to by the foreign key.
|
2017-05-09 21:30:04 +02:00
|
|
|
func (o *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}(exec boil.Executor, mods ...qm.QueryMod) ({{$tableNameSingular}}Query) {
|
2016-09-19 01:26:30 +02:00
|
|
|
queryMods := []qm.QueryMod{
|
2016-11-16 06:55:20 +01:00
|
|
|
qm.Where("{{$txt.ForeignTable.ColumnName}}=?", o.{{$txt.LocalTable.ColumnNameGo}}),
|
2016-09-19 01:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
queryMods = append(queryMods, mods...)
|
|
|
|
|
|
|
|
query := {{$txt.ForeignTable.NamePluralGo}}(exec, queryMods...)
|
2016-09-21 06:05:26 +02:00
|
|
|
queries.SetFrom(query.Query, "{{.ForeignTable | $dot.SchemaTable}}")
|
2016-09-19 01:26:30 +02:00
|
|
|
|
|
|
|
return query
|
|
|
|
}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|