ff-admin-server/src/command/protocolVotingCommandHandler.ts

26 lines
902 B
TypeScript
Raw Normal View History

2024-10-13 15:48:01 +02:00
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<SynchronizeProtocolVotingCommand>}
* @returns {Promise<void>}
*/
static async sync(syncProtocolVotings: Array<SynchronizeProtocolVotingCommand>): Promise<void> {
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);
});
}
}