sqlboiler/templates/01_types.tpl
Patrick O'brien 96d40fcfe4 Add automatic timestamps for created_at/updated_at
* Update and Insert
* Add --no-auto-timestamps flag
2016-08-29 00:12:37 +10:00

27 lines
1.3 KiB
Smarty

{{- $varNameSingular := .Table.Name | singular | camelCase -}}
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
var (
{{$varNameSingular}}Columns = []string{{"{"}}{{.Table.Columns | columnNames | stringMap .StringFuncs.quoteWrap | join ", "}}{{"}"}}
{{$varNameSingular}}ColumnsWithoutDefault = []string{{"{"}}{{.Table.Columns | filterColumnsByDefault false | columnNames | stringMap .StringFuncs.quoteWrap | join ","}}{{"}"}}
{{$varNameSingular}}ColumnsWithDefault = []string{{"{"}}{{.Table.Columns | filterColumnsByDefault true | columnNames | stringMap .StringFuncs.quoteWrap | join ","}}{{"}"}}
{{$varNameSingular}}PrimaryKeyColumns = []string{{"{"}}{{.Table.PKey.Columns | stringMap .StringFuncs.quoteWrap | join ", "}}{{"}"}}
{{$varNameSingular}}TitleCases = map[string]string{
{{range $col := .Table.Columns | columnNames -}}
"{{$col}}": "{{titleCase $col}}",
{{end -}}
}
)
type (
{{$tableNameSingular}}Slice []*{{$tableNameSingular}}
{{if eq .NoHooks false -}}
{{$tableNameSingular}}Hook func(*{{$tableNameSingular}}) error
{{- end}}
{{$varNameSingular}}Query struct {
*boil.Query
}
)
// Force time package dependency for automated UpdatedAt/CreatedAt.
var _ = time.Second