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