Add name to User

This commit is contained in:
Jan Bader 2016-12-19 18:46:32 +01:00
parent c0d6ae1157
commit 099ae5fe8a
2 changed files with 7 additions and 4 deletions

View File

@ -14,8 +14,8 @@ type UserService struct {
// User returns a user for a given id.
func (s *UserService) User(id int) (*budgeteer.User, error) {
var u budgeteer.User
row := s.DB.QueryRow(`SELECT id, email, password FROM users WHERE id = $1`, id)
if err := row.Scan(&u.ID, &u.Email, &u.Password); err != nil {
row := s.DB.QueryRow(`SELECT id, email, password, name FROM users WHERE id = $1`, id)
if err := row.Scan(&u.ID, &u.Email, &u.Password, &u.Name); err != nil {
return nil, err
}
return &u, nil

View File

@ -1,11 +1,14 @@
package budgeteer
// User struct contains Login information
type User struct {
ID int
Email string
Password string
Name string
}
// UserService provides Methods for CRUD of Users
type UserService interface {
User(id int) (*User, error)
//Users() ([]*User, error)