import { dataSource } from "../../../data-source"; import { protocolAgenda } from "../../../entity/club/protocol/protocolAgenda"; import DatabaseActionException from "../../../exceptions/databaseActionException"; import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolAgendaService { /** * @description get all protocolAgendas * @returns {Promise>} */ static async getAll(protocolId: number): Promise> { return await dataSource .getRepository(protocolAgenda) .createQueryBuilder("protocolAgenda") .where("protocolAgenda.protocolId = :protocolId", { protocolId }) .getMany() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "protocolAgenda", err); }); } /** * @description get protocolAgenda by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(protocolAgenda) .createQueryBuilder("protocolAgenda") .where("protocolAgenda.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "protocolAgenda", err); }); } /** * @description get count of exisiting protocolAgenda by protocolId * @returns {Promise} */ static async getInstanceCount(protocolId: number): Promise { return await dataSource .getRepository(protocolAgenda) .createQueryBuilder("protocolAgenda") .where({ protocolId }) .getCount() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("COUNT", "protocolAgenda", err); }); } }