Cloudreve/ent/templates/edgehelper.tmpl
AaronLiu 21d158db07
Init V4 community edition (#2265)
* Init V4 community edition

* Init V4 community edition
2025-04-20 17:31:25 +08:00

20 lines
630 B
Cheetah

{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Type type. */}}
{{/* gotype: entgo.io/ent/entc/gen.Type */}}
{{ define "model/additional/edgehelper" }}
{{/* A template that adds the "GoString" method to all generated models on the same file they are defined. */}}
{{- with $.Edges }}
{{- range $i, $e := . }}
// Set{{ $e.StructField }} manually set the edge as loaded state.
func (e *{{ $.Name }}) Set{{ $e.StructField }}(v {{ if not $e.Unique }}[]{{ end }}*{{ $e.Type.Name }}) {
e.Edges.{{ $e.StructField }} = v
e.Edges.loadedTypes[{{ $i }}] = true
}
{{- end }}
{{- end }}
{{ end }}