Gorm 创建
创建对象
通过数据指针创建
不带 default(会设置默认值)
type User struct {
gorm.Model
Name string
Age uint
Birthday *time.Time
Nickname *string
Address string
}
func TestCreate(t *testing.T) {
time := time.Now()
user := User{
Name: "tiecheng",
Age: 18,
Birthday: &time,
}
DB.Create(&user)
}default 设置
高端插入(Upsert)
项目实战
主键回填失败

输出 SQL打印对不上
最后更新于