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