代码如下。
type xxxx struct {
ID int gorm:"column:id"
Email string gorm:"column:email"
Mobile string gorm:"column:mobile"
CompanyPhone string gorm:"column:company_phone"
BankName string gorm:"column:bank_name"
BankAccount string gorm:"column:bank_account"
}
func UpdateWwcFapiao(w []xxxx) error { if err := db.Table(tableName).Updates(w).Error; err != nil { return err } return nil }
if err := dao.UpdateWwcFapiao(w); err != nil {
log.Fatalf("udpate table wwc_fapiao is err:%v\n", err)
}
提示我:unsupported data 这个是什么原因呢 是我用的方法不对吗
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: ghost
Updates 方法支持 struct 和 map[string]interface{} 参数。当使用 struct 更新时,默认情况下,GORM 只会更新非零值的字段
https://gorm.cn/zh_CN/docs/update.html#%E6%9B%B4%E6%96%B0%E5%A4%9A%E5%88%97
Comment From: kuangshp
Updates 方法支持 struct 和 map[string]interface{} 参数。当使用 struct 更新时,默认情况下,GORM 只会更新非零值的字段https://gorm.cn/zh_CN/docs/update.html#%E6%9B%B4%E6%96%B0%E5%A4%9A%E5%88%97
有没有办法类似删除一样的,加一个方法就可以实现更新默认值,每次我在更新的时候都写map的方式,很不好