for example, i want to map struct Employee to table prefix_employee.
xorm has already support this.
Create a method called TableName() on the struct to give a custom name.
thanks @pjebs for your reply. the way you provided means i have to define this TableName() for every struct, i think it will be better if gorm has builtin similar mechanism.
General mapping rules definition/override would be nice for tables as well as columns.
Overwrite the DefaultTableNameHandler method
@jinzhu It doesn't work in using db.AutoMigrate(Model{}) or db.First(Model{}).
Because DefaultNameHandler is called only from ModelStruct.
If a model implements tabler interface, DefaultNameHandler is never called.
So, I create pull request. Please take a look?
https://github.com/jinzhu/gorm/pull/1688
Most helpful comment
thanks @pjebs for your reply. the way you provided means i have to define this
TableName()for every struct, i think it will be better if gorm has builtin similar mechanism.