This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.
Add another method of setting table name. #89
Labels
At the moment if your table name is not the same as the class name you got to set it for every single operation e.g.: session.Table("users").Find(&users). Would be nice if you could set it on the struct such as:
type User struct {
Id int64
xorm:"id"
UserName string
xorm:"username"
FullName string
xorm:"full_name"
}
func (this User) TableName() {
return "users"
}
I like the idea of declaring the table once and then using the fields instead of stating table and column names and use Go's type system. It makes it easier to rename columns in the future and make the compiler help you catch references to it.
The text was updated successfully, but these errors were encountered: