26 lines
868 B
TypeScript
26 lines
868 B
TypeScript
|
import { dataSource } from "../data-source";
|
||
|
import { protocolAgenda } from "../entity/protocolAgenda";
|
||
|
import InternalException from "../exceptions/internalException";
|
||
|
import { SynchronizeProtocolAgendaCommand } from "./protocolAgendaCommand";
|
||
|
|
||
|
export default abstract class ProtocolAgendaCommandHandler {
|
||
|
/**
|
||
|
* @description sync protocolAgenda
|
||
|
* @param {Array<SynchronizeProtocolAgendaCommand>}
|
||
|
* @returns {Promise<void>}
|
||
|
*/
|
||
|
static async sync(syncProtocolAgenda: Array<SynchronizeProtocolAgendaCommand>): Promise<void> {
|
||
|
return await dataSource
|
||
|
.createQueryBuilder()
|
||
|
.insert()
|
||
|
.into(protocolAgenda)
|
||
|
.values(syncProtocolAgenda)
|
||
|
.orUpdate(["topic", "context"], ["id"])
|
||
|
.execute()
|
||
|
.then(() => {})
|
||
|
.catch((err) => {
|
||
|
throw new InternalException("Failed creating protocol", err);
|
||
|
});
|
||
|
}
|
||
|
}
|