/*
* This file is part of sdbapi
* Copyright (C) 2022 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
package db
import (
"api/models"
"api/apierror"
)
// get a user with an ID
func GetUserByID(id string) (models.User, *apierror.APIError) {
var user models.User
user_record := DbConn.Where("id = ?", id).First(&user)
if user_record.Error != nil {
return models.User{}, &apierror.UserNotFound
}
return user, nil
}
// get a user with an email address
func GetUserByEmail(email string) (models.User, *apierror.APIError) {
var user models.User
user_record := DbConn.Where("email = ?", email).First(&user)
if user_record.Error != nil {
return models.User{}, &apierror.UserNotFound
}
return user, nil
}