"sql:"-"" 在 Go 语言 GORM 中代表什么?
What "sql:"-"" represents in Go lang GORM?
在此article,博主为其GORM模型编写代码如下
type Account struct {
gorm.Model
Email string `json:"email"`
Password string `json:"password"`
Token string `json:"token";sql:"-"`
}
我不确定 sql:"-" 在这个模型中代表什么?也无法在 google 中获得结果。我是 GO 的新手,对此的帮助将不胜感激
在老版本的GORM中,sql:"-"
表示忽略该字段。新版本的 GORM 使用 gorm:"-"
代替。 here
在此article,博主为其GORM模型编写代码如下
type Account struct {
gorm.Model
Email string `json:"email"`
Password string `json:"password"`
Token string `json:"token";sql:"-"`
}
我不确定 sql:"-" 在这个模型中代表什么?也无法在 google 中获得结果。我是 GO 的新手,对此的帮助将不胜感激
在老版本的GORM中,sql:"-"
表示忽略该字段。新版本的 GORM 使用 gorm:"-"
代替。 here