entc/gen: initial support for user-defined ids

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/162

Reviewed By: alexsn

Differential Revision: D18485086

fbshipit-source-id: 9bb6ccff592bc0cb8b218625161ed492f67bc170
This commit is contained in:
Ariel Mashraki
2019-11-14 08:19:54 -08:00
committed by Facebook Github Bot
parent e161ecc29c
commit d9da7243f9
33 changed files with 3748 additions and 26 deletions

View File

@@ -17,11 +17,14 @@ in the LICENSE file in the root directory of this source tree.
// {{ $builder }} is the builder for creating a {{ $.Name }} entity.
type {{ $builder }} struct {
config
{{- if $.ID.UserDefined }}
{{ $.ID.BuilderField }} *{{ $.ID.Type }}
{{- end }}
{{ range $_, $f := $.Fields }}
{{- $f.BuilderField }} *{{ $f.Type }}
{{ end }}
{{- range $_, $e := $.Edges }}
{{- $e.BuilderField }} map[{{ $.ID.Type }}]struct{}
{{- $e.BuilderField }} map[{{ $e.Type.ID.Type }}]struct{}
{{ end -}}
}