2016-08-09 04:33:10 +02:00
|
|
|
{{- define "relationship_to_one_struct_helper" -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2016-09-04 15:44:54 +02:00
|
|
|
{{- $dot := . -}}
|
2016-08-04 07:34:46 +02:00
|
|
|
{{- $tableNameSingular := .Table.Name | singular -}}
|
|
|
|
{{- $modelName := $tableNameSingular | titleCase -}}
|
2016-09-01 05:33:05 +02:00
|
|
|
{{- $modelNameCamel := $tableNameSingular | camelCase -}}
|
2016-08-04 07:34:46 +02:00
|
|
|
// {{$modelName}} is an object representing the database table.
|
|
|
|
type {{$modelName}} struct {
|
2016-09-14 10:08:30 +02:00
|
|
|
{{range $column := .Table.Columns -}}
|
|
|
|
{{titleCase $column.Name}} {{$column.Type}} `{{generateTags $dot.Tags $column.Name}}boil:"{{$column.Name}}" json:"{{$column.Name}}{{if $column.Nullable}},omitempty{{end}}" toml:"{{$column.Name}}" yaml:"{{$column.Name}}{{if $column.Nullable}},omitempty{{end}}"`
|
|
|
|
{{end -}}
|
|
|
|
{{- if .Table.IsJoinTable -}}
|
|
|
|
{{- else}}
|
|
|
|
R *{{$modelNameCamel}}R `{{generateIgnoreTags $dot.Tags}}boil:"-" json:"-" toml:"-" yaml:"-"`
|
|
|
|
L {{$modelNameCamel}}L `{{generateIgnoreTags $dot.Tags}}boil:"-" json:"-" toml:"-" yaml:"-"`
|
|
|
|
{{end -}}
|
2016-08-09 04:33:10 +02:00
|
|
|
}
|
|
|
|
|
2017-05-08 22:30:40 +02:00
|
|
|
// {{$modelName}}Filter allows you to filter on any columns by making them all pointers.
|
|
|
|
type {{$modelName}}Filter struct {
|
|
|
|
{{range $column := .Table.Columns -}}
|
|
|
|
{{titleCase $column.Name}} *{{$column.Type}} `{{generateTags $dot.Tags $column.Name}}boil:"{{$column.Name}}" json:"{{$column.Name}},omitempty" toml:"{{$column.Name}}" yaml:"{{$column.Name}},omitempty"`
|
|
|
|
{{end -}}
|
|
|
|
}
|
|
|
|
|
2016-08-09 04:33:10 +02:00
|
|
|
{{- if .Table.IsJoinTable -}}
|
|
|
|
{{- else}}
|
2016-09-01 05:33:05 +02:00
|
|
|
// {{$modelNameCamel}}R is where relationships are stored.
|
|
|
|
type {{$modelNameCamel}}R struct {
|
2016-09-14 10:08:30 +02:00
|
|
|
{{range .Table.FKeys -}}
|
2016-09-18 20:18:55 +02:00
|
|
|
{{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
|
|
|
|
{{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}}
|
2016-09-14 10:08:30 +02:00
|
|
|
{{end -}}
|
2016-09-18 20:18:55 +02:00
|
|
|
|
2016-09-19 01:02:08 +02:00
|
|
|
{{range .Table.ToOneRelationships -}}
|
2016-09-18 20:18:55 +02:00
|
|
|
{{- $txt := txtsFromOneToOne $dot.Tables $dot.Table . -}}
|
|
|
|
{{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}}
|
|
|
|
{{end -}}
|
|
|
|
|
2016-09-19 01:02:08 +02:00
|
|
|
{{range .Table.ToManyRelationships -}}
|
2016-09-18 20:18:55 +02:00
|
|
|
{{- $txt := txtsFromToMany $dot.Tables $dot.Table . -}}
|
|
|
|
{{$txt.Function.Name}} {{$txt.ForeignTable.Slice}}
|
2016-09-19 01:02:08 +02:00
|
|
|
{{end -}}{{/* range tomany */}}
|
2016-02-23 09:27:32 +01:00
|
|
|
}
|
2016-09-02 03:01:20 +02:00
|
|
|
|
|
|
|
// {{$modelNameCamel}}L is where Load methods for each relationship are stored.
|
|
|
|
type {{$modelNameCamel}}L struct{}
|
2016-08-09 04:33:10 +02:00
|
|
|
{{end -}}
|