fathom/datastore/users.go

22 lines
625 B
Go
Raw Normal View History

2017-01-25 16:11:35 +00:00
package datastore
import (
"github.com/dannyvankooten/ana/models"
)
var u models.User
// GetUser retrieves user from datastore by its ID
2017-01-25 16:11:35 +00:00
func GetUser(id int64) (*models.User, error) {
stmt, err = DB.Prepare("SELECT id, email FROM users WHERE id = ? LIMIT 1")
err = stmt.QueryRow(id).Scan(&u.ID, &u.Email)
return &u, err
}
// GetUserByEmail retrieves user from datastore by its email
2017-01-25 16:11:35 +00:00
func GetUserByEmail(email string) (*models.User, error) {
stmt, err = DB.Prepare("SELECT id, email, password FROM users WHERE email = ? LIMIT 1")
err = stmt.QueryRow(email).Scan(&u.ID, &u.Email, &u.HashedPassword)
2017-01-25 16:11:35 +00:00
return &u, err
}