go-gorm 是 jinzhu的grom 第二版本
之前没注意第一版本只更新到1.9。 现在的第二版 已经到1.21了
文档
https://gorm.io/zh_CN/docs/create.html
升级遇到问题
问题: cannot use &count (type *int) as type *int64 in argument to db.Count
解决:int 改为int64
问题: not enough arguments in call to helpers.MysqlClient.Model(&DeliveryRules{}).Where("rule_id = ?", d.RuleID).Update
have (map[string]interface {})
want (string, interface {})
解决:Update. 改为 Updates
.Limit(limit).Offset(offset) limit 和 offset 都是int类型
问题:需求录入查询不到数据
解决:单条查询要用First。判断用 err != 'record not found' 多条查询用Find。 判断用len()