我只想停用我的 gorm 模型的 created_at 和 updated_at 字段,但無法在文檔中找到它。嘗試在數據庫中創建行時出現此錯誤:Error 1054: Unknown column 'created_at' in 'field list'
1 回答

慕容3067478
TA貢獻1773條經驗 獲得超3個贊
created_at、id、updated_at、deleted_at 字段通過將 gorm.Model 嵌入到您的結構中來嵌入到您的模型中。
所以,禁用它們而不是做
type Product struct {
gorm.Model
Code string
Price uint
}
做
type Product struct {
ID uint `gorm:"primarykey"`
Code string
Price uint
}
- 1 回答
- 0 關注
- 139 瀏覽
添加回答
舉報
0/150
提交
取消