[Golang系列] GOFLY在线客服-解决gorm在update时没有表名-GO语言实现开源独立部署客服系统

当进去表的update操作的时候

报错说,不正确的表名

查看日志发现sql语句里面没有表名

需要在update操作的时候,Model()方法指定好要更新的表struct类型

官方的注释

// update all users's name to `hello`
   db.Model(&User{}).Update("name", "hello")
   // if user's primary key is non-blank, will use it as condition, then will only update the user's name to `hello`
   db.Model(&user).Update("name", "hello")

.Model方法,参数必须这样的,&User{} 这种结构体指针 ,user这个是结构体或者指针的情况下,也要再&取一下地址