support group edges via scaffold

This commit is contained in:
Hayden 2023-03-05 21:56:53 -09:00
parent 9fa4da819f
commit 737007b156
No known key found for this signature in database
GPG key ID: 17CF79474E257545
4 changed files with 57 additions and 1 deletions

View file

@ -14,6 +14,20 @@ questions:
message: "What is the name of the model? (PascalCase)"
required: true
- name: "by_group"
prompt:
confirm: "Include a Group Edge? (group_id -> id)"
required: true
rewrites:
- from: 'templates/model.go'
to: 'backend/internal/data/ent/schema/{{ lower .Scaffold.model }}.go'
to: 'backend/internal/data/ent/schema/{{ lower .Scaffold.model }}.go'
inject:
- name: "Insert Groups Edge"
path: 'backend/internal/data/ent/schema/group.go'
at: // $scaffold_edge
template: |
{{- if .Scaffold.by_group -}}
owned("{{ lower .Scaffold.model }}s", {{ .Scaffold.model }}.Type),
{{- end -}}