You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking for a way to add a tag to the model gen with a directive, for things like ORMs and Validation of stuct fields, is there a way to hook into that? Or is this not currently possible?
The text was updated successfully, but these errors were encountered:
nurdism
changed the title
Question/Suggestion: Hook into plugin into modelgen
Question/Suggestion: Hook plugin into modelgen
Sep 24, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This change introduces option to implement custom hook for model
generation plugin without the need to completly copy the whole `modelgen` plugin.
One very possible case is as described in 99designs#876 and with this change the solution for
that can be:
```golang
func mutateHook(b *ModelBuild) *ModelBuild {
for _, model := range b.Models {
for _, field := range model.Fields {
field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"`
}
}
return b
}
...
func main() {
p := modelgen.Plugin {
MutateHook: mutateHook,
}
...
}
```
I was looking for a way to add a tag to the model gen with a directive, for things like ORMs and Validation of stuct fields, is there a way to hook into that? Or is this not currently possible?
The text was updated successfully, but these errors were encountered: