8757c8a184
- Move most files to root - Remove cmds directory in favor of cmd directory with binary - Remove all cobra from main
32 lines
1.3 KiB
Smarty
32 lines
1.3 KiB
Smarty
{{- $varNameSingular := camelCaseSingular .Table.Name -}}
|
|
var {{$varNameSingular}}Columns = []string{{"{"}}{{columnsToStrings .Table.Columns | commaList}}{{"}"}}
|
|
var {{$varNameSingular}}ColumnsWithoutDefault = []string{{"{"}}{{filterColumnsByDefault .Table.Columns false}}{{"}"}}
|
|
var {{$varNameSingular}}ColumnsWithDefault = []string{{"{"}}{{filterColumnsByDefault .Table.Columns true}}{{"}"}}
|
|
var {{$varNameSingular}}PrimaryKeyColumns = []string{{"{"}}{{commaList .Table.PKey.Columns}}{{"}"}}
|
|
var {{$varNameSingular}}AutoIncrementColumns = []string{{"{"}}{{filterColumnsByAutoIncrement .Table.Columns}}{{"}"}}
|
|
var {{$varNameSingular}}AutoIncPrimaryKey = "{{autoIncPrimaryKey .Table.Columns .Table.PKey}}"
|
|
|
|
{{if hasPrimaryKey .Table.PKey -}}
|
|
{{- $tableNameSingular := titleCaseSingular .Table.Name -}}
|
|
func (o {{$tableNameSingular}}) inPrimaryKeyArgs() []interface{} {
|
|
var args []interface{}
|
|
|
|
{{- range $key, $value := .Table.PKey.Columns }}
|
|
args = append(args, o.{{titleCase $value}})
|
|
{{ end -}}
|
|
|
|
return args
|
|
}
|
|
|
|
func (o {{$varNameSingular}}Slice) inPrimaryKeyArgs() []interface{} {
|
|
var args []interface{}
|
|
|
|
for i := 0; i < len(o); i++ {
|
|
{{- range $key, $value := .Table.PKey.Columns }}
|
|
args = append(args, o[i].{{titleCase $value}})
|
|
{{ end -}}
|
|
}
|
|
|
|
return args
|
|
}
|
|
{{- end}}
|