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
modelValue := reflect.New(modelType)
tableName := namer.TableName(modelType.Name())
if tabler, ok := modelValue.Interface().(Tabler); ok {
tableName = tabler.TableName()
}
why use reflect.New(modelType)??
if I define a struct like:
type Device struct {
ID uint `gorm:"primary_key"`
Name string `gorm:"size:32"`
TbNameSuffix int `gorm:"-"`
}
func (sf *Device) TableName() string {
return "devices_"+strconv.Itoa(sf.TbNameSuffix)
}
i want to generate table name dynamically: device_0,devices_1,... with give struct field TbNameSuffix.
I want to dynamically generated table name, alway get devices_0.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale as it missing playground pull request link, checkout https://github.com/go-gorm/playground for details, it will be closed in 2 days if no further activity occurs.
GORM Playground Link
go-gorm/playground#1
Description
in schem.go code 91-95
why use reflect.New(modelType)??
if I define a struct like:
i want to generate table name dynamically: device_0,devices_1,... with give struct field TbNameSuffix.
I want to dynamically generated table name, alway get
devices_0
.The text was updated successfully, but these errors were encountered: