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

26 lines
868 B
TypeScript
Raw Normal View History

2024-10-13 13:48:01 +00:00
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);
});
}
}