Open NoSugarCoffee opened 1 year ago
I have the same issue. This cannot be solved with the gorm hooks as long as they have to be defined on/for the model itself (func (m *Model) BeforeSave
) because this inevitably creates the import cycle.
The only solution that comes to mind is having hooks outside of gorm called before db.Save()
, which is ... not really nice.
Your Question
The GEN seems extract
dao
layer like java, but seems a little problem with gorm hook.Imagine that:
it cause
import cycle
between dao and model because we also usedao
api inmodel
layer under the hookso seems only can use raw gorm query under the hook or put GEN generated code to models/, is it right?
I have't use GEN with my project, but I think it can imporve our development efficiency and easy to write tests
The document you expected this should be explained
Expected answer
Give an advice about the question, thanks a lot.