Code generation for structs for tables
This commit is contained in:
committed by
Michal Jan Matczuk
parent
3e151149a0
commit
2942397ab6
@@ -2,7 +2,12 @@
|
||||
|
||||
package {{.PackageName}}
|
||||
|
||||
import "github.com/scylladb/gocqlx/v2/table"
|
||||
import (
|
||||
"github.com/scylladb/gocqlx/v2/table"
|
||||
{{- range .Imports}}
|
||||
"{{.}}"
|
||||
{{- end}}
|
||||
)
|
||||
|
||||
// Table models.
|
||||
var (
|
||||
@@ -30,3 +35,27 @@ var (
|
||||
{{end}}
|
||||
{{end}}
|
||||
)
|
||||
|
||||
{{with .UserTypes}}
|
||||
{{range .}}
|
||||
{{- $type_name := .Name | camelize}}
|
||||
{{- $field_types := .FieldTypes}}
|
||||
type {{$type_name}}Type struct {
|
||||
{{- range $index, $element := .FieldNames}}
|
||||
{{- $type := index $field_types $index}}
|
||||
{{. | camelize}} {{getNativeTypeSting $type | mapScyllaToGoType}}
|
||||
{{- end}}
|
||||
}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
{{with .Tables}}
|
||||
{{range .}}
|
||||
{{- $model_name := .Name | camelize}}
|
||||
type {{$model_name}}Struct struct {
|
||||
{{- range .Columns}}
|
||||
{{.Name | camelize}} {{.Validator | mapScyllaToGoType}}
|
||||
{{- end}}
|
||||
}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
Reference in New Issue
Block a user