Your Question
Is there an opposite to Omit? Pretty much every server will have a User model with a password field. Usually we would write something like :
type User struct {
Id string `json:"id,omitempty" gorm:"primary_key"`
Password string `json:"password,omitempty" gorm:"-"`
}
But in the times that you actually need to compare the password on logins or to update the password on password change, how would we do that? Right now it seems like i would need to write omit everywhere on user queries except for the 2 places where I actually want it included.
The document you expected this should be explained
Expected answer
Write something like db.Include("password").First(&user)
Comment From: ghost
https://gorm.io/docs/update.html#Update-Selected-Fields
Comment From: github-actions[bot]
This issue has been automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days
Comment From: jinzhu
Select