What I like to do is something like, wrap the gorm functionality behinde some functions without specific struct params.
func (e *Engine) Create(object interface{}) error {
tx := e.db.Begin()
if err := tx.Create(&object).Error; err != nil {
tx.Rollback()
return err
}
tx.Commit()
return nil
}
The specific table exists, created with db.CreateTable(&<specific struct{})
.
But the it fails with the following error:
Can't create <specific struct>: no such table:
Is this a way to go with gorm/golang or not and if how this is to wrap?