type Products struct {
	gorm.Model
	SaleNum  uint    ` json:"saleNum"`
	CarNum   uint    ` json:"carNum"`
}

上面的结构体 到数据库中查询的时候会自动将 saleNum carNum 转成 sale_num car_num

如果不想转变 就需要使用 gorm:"column:saleNum" gorm:"column:carNum"

type Products struct {
	gorm.Model
	SaleNum  uint    `gorm:"column:saleNum" json:"saleNum"`
	CarNum   uint    `gorm:"column:carNum" json:"carNum"`
}

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2021-12-19
  • 2021-09-19
  • 2021-12-28
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2022-01-19
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案