Generate ent schema in admin code. (#127)

This commit is contained in:
Mike Stefanello 2025-08-04 08:32:10 -04:00 committed by GitHub
parent 67a97832a5
commit 9e6d9fd063
13 changed files with 303 additions and 142 deletions

View file

@ -0,0 +1,54 @@
{{/* Tell Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}}
{{/* gotype: entgo.io/ent/entc/gen.Graph */}}
{{ define "admin/schema" }}
// Code generated by ent, DO NOT EDIT.
package admin
import (
"entgo.io/ent/schema/field"
)
type Enum struct {
Label, Value string
}
type FieldSchema struct {
Name string
Type field.Type
Optional bool
Immutable bool
Sensitive bool
Enums []Enum
}
{{- range $n := $.Nodes }}
const Name{{ $n.Name }} = "{{ $n.Name }}"
var fields{{ $n.Name }} = []*FieldSchema{
{{- range $f := $n.Fields }}
{
Name: "{{ $f.Name }}",
Type: field.{{ $f.Type.Type.ConstName }},
Optional: {{ $f.Optional }},
Immutable: {{ $f.Immutable }},
Sensitive: {{ $f.Sensitive }},
{{- if len $f.Enums }}
Enums: []Enum{
{{- range $e := $f.Enums }}
{
Label: "{{ $e.Label }}",
Value: "{{ $e.Value }}",
},
{{- end }}
},
{{- else }}
Enums: nil,
{{- end }}
},
{{- end }}
}
{{ end }}
{{ end }}