2016-09-03 21:47:27 +02:00
|
|
|
{{if .Table.IsJoinTable -}}
|
|
|
|
{{else -}}
|
2016-06-20 07:22:50 +02:00
|
|
|
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
|
|
|
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
|
2016-06-20 01:29:59 +02:00
|
|
|
var (
|
2016-09-15 06:27:06 +02:00
|
|
|
{{$varNameSingular}}Columns = []string{{"{"}}{{.Table.Columns | columnNames | stringMap .StringFuncs.quoteWrap | join ", "}}{{"}"}}
|
2017-03-16 08:54:55 +01:00
|
|
|
{{if eq .DriverName "mssql" -}}
|
2017-03-19 10:42:55 +01:00
|
|
|
{{$varNameSingular}}ColumnsWithAuto = []string{{"{"}}{{.Table.Columns | filterColumnsByAuto true | columnNames | stringMap .StringFuncs.quoteWrap | join ","}}{{"}"}}
|
2017-03-31 10:03:16 +02:00
|
|
|
{{end -}}
|
2016-09-15 06:27:06 +02:00
|
|
|
{{$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 ", "}}{{"}"}}
|
2016-06-20 01:29:59 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2016-09-15 06:20:35 +02:00
|
|
|
// {{$tableNameSingular}}Slice is an alias for a slice of pointers to {{$tableNameSingular}}.
|
|
|
|
// This should generally be used opposed to []{{$tableNameSingular}}.
|
2016-09-14 10:08:30 +02:00
|
|
|
{{$tableNameSingular}}Slice []*{{$tableNameSingular}}
|
2016-09-21 06:07:50 +02:00
|
|
|
{{if not .NoHooks -}}
|
2016-09-15 06:20:35 +02:00
|
|
|
// {{$tableNameSingular}}Hook is the signature for custom {{$tableNameSingular}} hook methods
|
2016-09-14 10:08:30 +02:00
|
|
|
{{$tableNameSingular}}Hook func(boil.Executor, *{{$tableNameSingular}}) error
|
|
|
|
{{- end}}
|
2016-07-14 07:09:05 +02:00
|
|
|
|
2017-05-09 21:30:04 +02:00
|
|
|
{{$tableNameSingular}}Query struct {
|
2016-09-15 05:59:55 +02:00
|
|
|
*queries.Query
|
2016-09-14 10:08:30 +02:00
|
|
|
}
|
2016-06-20 01:29:59 +02:00
|
|
|
)
|
2016-08-28 16:12:37 +02:00
|
|
|
|
2016-09-15 08:03:05 +02:00
|
|
|
// Cache for insert, update and upsert
|
2016-09-03 21:24:18 +02:00
|
|
|
var (
|
2016-09-14 10:08:30 +02:00
|
|
|
{{$varNameSingular}}Type = reflect.TypeOf(&{{$tableNameSingular}}{})
|
2016-09-15 05:59:55 +02:00
|
|
|
{{$varNameSingular}}Mapping = queries.MakeStructMapping({{$varNameSingular}}Type)
|
2016-09-16 08:44:44 +02:00
|
|
|
{{$varNameSingular}}PrimaryKeyMapping, _ = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, {{$varNameSingular}}PrimaryKeyColumns)
|
2016-09-14 10:08:30 +02:00
|
|
|
{{$varNameSingular}}InsertCacheMut sync.RWMutex
|
|
|
|
{{$varNameSingular}}InsertCache = make(map[string]insertCache)
|
|
|
|
{{$varNameSingular}}UpdateCacheMut sync.RWMutex
|
|
|
|
{{$varNameSingular}}UpdateCache = make(map[string]updateCache)
|
2016-09-15 08:03:05 +02:00
|
|
|
{{$varNameSingular}}UpsertCacheMut sync.RWMutex
|
|
|
|
{{$varNameSingular}}UpsertCache = make(map[string]insertCache)
|
2016-09-03 21:24:18 +02:00
|
|
|
)
|
|
|
|
|
2016-09-16 09:22:12 +02:00
|
|
|
var (
|
|
|
|
// Force time package dependency for automated UpdatedAt/CreatedAt.
|
|
|
|
_ = time.Second
|
|
|
|
// Force bytes in case of primary key column that uses []byte (for relationship compares)
|
|
|
|
_ = bytes.MinRead
|
|
|
|
)
|
2016-09-03 21:47:27 +02:00
|
|
|
{{end -}}
|