use default null instead of pointer to primary key

This commit is contained in:
sentriz
2019-05-27 11:22:01 +01:00
parent 4b66a84985
commit 601cf560d0
9 changed files with 58 additions and 56 deletions

View File

@@ -38,6 +38,12 @@ func (c *Controller) SetSetting(key, value string) {
func (c *Controller) GetUserFromName(name string) *model.User {
var user model.User
c.DB.Where("name = ?", name).First(&user)
err := c.DB.
Where("name = ?", name).
First(&user).
Error
if gorm.IsRecordNotFoundError(err) {
return nil
}
return &user
}