doc/hooks: add example for post mutation action (#2161)

* update hooks documentation to a post hook example

* Update doc/md/hooks.md

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
Yoni Davidson
2021-11-24 13:46:04 +02:00
committed by GitHub
parent 2000e1970b
commit 3cb4bc324a

View File

@@ -184,7 +184,10 @@ func (Card) Hooks() []ent.Hook {
if s, ok := m.(interface{ SetName(string) }); ok {
s.SetName("Boring")
}
return next.Mutate(ctx, m)
v, err := next.Mutate(ctx, m)
// Post mutation action.
fmt.Println("new value:", v)
return v, err
})
},
}