sqlboiler/templates/18_helpers.tpl
2016-08-29 22:58:55 -07:00

23 lines
619 B
Smarty

{{- $varNameSingular := .Table.Name | singular | camelCase -}}
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
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 {{$tableNameSingular}}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
}