From 099ae5fe8abcb20222ca245148d461a5e10426dd Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Mon, 19 Dec 2016 18:46:32 +0100 Subject: [PATCH] Add name to User --- postsgres/userservice.go | 4 ++-- user.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/postsgres/userservice.go b/postsgres/userservice.go index 2b13df1..ce54e7a 100644 --- a/postsgres/userservice.go +++ b/postsgres/userservice.go @@ -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 diff --git a/user.go b/user.go index a40e046..c099f95 100644 --- a/user.go +++ b/user.go @@ -1,14 +1,17 @@ package budgeteer +// User struct contains Login information type User struct { - ID int + 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) //CreateUser(u *User) error //DeleteUser(id int) error -} \ No newline at end of file +}