import { dataSource } from "../data-source"; import { protocolVoting } from "../entity/protocolVoting"; import InternalException from "../exceptions/internalException"; import { SynchronizeProtocolVotingCommand } from "./protocolVotingCommand"; export default abstract class ProtocolVotingCommandHandler { /** * @description sync protocolVoting * @param {Array} * @returns {Promise} */ static async sync(syncProtocolVotings: Array): Promise { return await dataSource .createQueryBuilder() .insert() .into(protocolVoting) .values(syncProtocolVotings) .orUpdate(["topic", "context", "favour", "abstain", "against"], ["id"]) .execute() .then(() => {}) .catch((err) => { throw new InternalException("Failed creating protocol", err); }); } }