mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add edge method for getting mutation-remove in templates
This commit is contained in:
committed by
Ariel Mashraki
parent
bd246f28dc
commit
9090c103be
File diff suppressed because one or more lines are too long
@@ -282,9 +282,8 @@ func (m *{{ $mutation }}) ID() (id {{ $n.ID.Type }}, exists bool) {
|
||||
|
||||
{{ if not $e.Unique }}
|
||||
{{ $p := lower (printf "%.1s" $e.Type.Name) }}
|
||||
{{ $idsFunc := print "Remove" (singular $e.Name | pascal) "IDs" }}
|
||||
// {{ $idsFunc }} removes the "{{ $e.Name }}" edge to the {{ $e.Type.Name }} entity by IDs.
|
||||
func (m *{{ $mutation }}) {{ $idsFunc }}(ids ...{{ $e.Type.ID.Type }}) {
|
||||
// {{ $e.MutationRemove }} removes the "{{ $e.Name }}" edge to the {{ $e.Type.Name }} entity by IDs.
|
||||
func (m *{{ $mutation }}) {{ $e.MutationRemove }}(ids ...{{ $e.Type.ID.Type }}) {
|
||||
if m.removed{{ $e.BuilderField }} == nil {
|
||||
m.removed{{ $e.BuilderField }} = make(map[{{ $e.Type.ID.Type }}]struct{})
|
||||
}
|
||||
|
||||
@@ -1396,6 +1396,11 @@ func (e Edge) MutationClear() string {
|
||||
return name
|
||||
}
|
||||
|
||||
// MutationRemove returns the method name for removing edge ids.
|
||||
func (e Edge) MutationRemove() string {
|
||||
return "Remove" + pascal(rules.Singularize(e.Name)) + "IDs"
|
||||
}
|
||||
|
||||
// MutationCleared returns the method name for indicating if the edge
|
||||
// was cleared in the mutation. The default name is "<EdgeName>Cleared".
|
||||
// If the the method conflicts with the mutation methods, add "Edge" the
|
||||
|
||||
Reference in New Issue
Block a user