GetUserByEmail finds a user by email
(email string)
| 105 | |
| 106 | // GetUserByEmail finds a user by email |
| 107 | func (a *App) GetUserByEmail(email string) (*database.User, error) { |
| 108 | var user database.User |
| 109 | err := a.DB.Where("email = ?", email).First(&user).Error |
| 110 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 111 | return nil, ErrNotFound |
| 112 | } else if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | |
| 116 | return &user, nil |
| 117 | } |
| 118 | |
| 119 | // GetAllUsers retrieves all users from the database |
| 120 | func (a *App) GetAllUsers() ([]database.User, error) { |
no outgoing calls