我在GORM中声明以下模型:
type DBModel struct {
ID uint `gorm:"primaryKey"`
CreatedAt *time.Time `json:"_"`
UpdatedAt *time.Time `json:"_"`
DeletedAt *time.Time `json:"_"`
ClientID uint `gorm:"not_null"`
}
type Address struct {
address string
city string
state string
pincode int
country string
}
type Office struct {
DBModel DBModel `gorm:"embedded"`
Address Address `gorm:"embedded"`
Name string
}
跑步时
func Init(db *gorm.DB) {
DB = db
DB.AutoMigrate(&models.Office{})
}
正在迁移的 Office 表包含以下字段:
id
created_at
updated_at
deleted_at
client_id
name
为什么地址结构未嵌入?
弑天下
相关分类