我正在使用 GORM,并且正在映射旧表。
默认情况下 GORM 有这个结构:
type Model struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt DeletedAt `gorm:"index"`
}
Run Code Online (Sandbox Code Playgroud)
我在旧表中没有 CreatedAt UpdatedAt DeletedAt 字段,我需要避免或禁用此默认结构。
我找不到避免这些专栏的方法。
您可以通过将 autoUpdateTime 标记设置为 false 来禁用时间戳跟踪,例如:Source
CreatedAt time.Time `gorm:"autoCreateTime:false"`
UpdatedAt time.Time `gorm:"autoUpdateTime:false"`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2220 次 |
| 最近记录: |