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