-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentity.go.tmpl
More file actions
32 lines (26 loc) · 1.06 KB
/
entity.go.tmpl
File metadata and controls
32 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/********************************
* {{ .GoName }}
{{- range $i, $f := .Fields }}
* {{ $f.GoName}} {{ $f.GoType }} {{ $f.SQLName }} {{ if $f.InPrimaryKey }} <primary> {{ end }} {{ if and ($.AutoIncrementField) (eq $f.GoName $.AutoIncrementField.GoName) }} <autoincrement> {{ end }}
{{- end }}
{{ if .PrimaryKey }} * Primary index: {{ .PrimaryKey }}{{ end }}
{{- if len .UniqIndexes }}
* Unique indexes: {{ range $n, $idx := .UniqIndexes }}
* {{ $n }}: {{ range $i, $f := $idx }}{{ if $i }}, {{ end }}{{ $f.SQLName }}{{ end }}
{{- end }}
{{- end }}
{{- if len .NonUniqIndexes }}
* Non unique indexes: {{ range $n, $idx := .NonUniqIndexes }}
* {{ $n }}: {{ range $i, $f := $idx }}{{ if $i }}, {{ end }}{{ $f.SQLName }}{{ end }}
{{- end }}
{{- end }}
********************************/
type {{ .GoName }}s []*{{ .GoName }}
type {{ .GoName }}OrErr struct {
Entity *{{ .GoName }}
Err error
}
{{ template "routines_create.go.tmpl" . }}
{{ template "routines_read.go.tmpl" . }}
{{ template "routines_update.go.tmpl" . }}
{{ template "routines_delete.go.tmpl" . }}