import { dataSource } from "../../../data-source"; import { inspection } from "../../../entity/unit/inspection/inspection"; import DatabaseActionException from "../../../exceptions/databaseActionException"; export default abstract class InspectionService { /** * @description get all inspection types * @returns {Promise>} */ static async getAll(): Promise> { return await dataSource .getRepository(inspection) .createQueryBuilder("inspection") .orderBy("type", "ASC") .getMany() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "inspection", err); }); } /** * @description get inspection by id * @returns {Promise} */ static async getById(id: string): Promise { return await dataSource .getRepository(inspection) .createQueryBuilder("inspection") .where({ id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "inspection", err); }); } }