Fix directory name 'postgres'

This commit is contained in:
2016-12-19 18:56:09 +01:00
parent 099ae5fe8a
commit 0cac7a69aa

22
postgres/userservice.go Normal file
View File

@ -0,0 +1,22 @@
package postgres
import (
"database/sql"
"git.javil.eu/jacob1123/budgeteer"
)
// UserService represents a PostgreSQL implementation of myapp.UserService.
type UserService struct {
DB *sql.DB
}
// 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, 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
}