import { dataSource } from "../data-source"; import { role } from "../entity/role"; import InternalException from "../exceptions/internalException"; export default abstract class RoleService { /** * @description get role by id * @param id number * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(role) .createQueryBuilder("role") .where("role.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("role not found by id"); }); } }