26 lines
902 B
TypeScript
26 lines
902 B
TypeScript
|
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);
|
||
|
});
|
||
|
}
|
||
|
}
|