import { dataSource } from "../data-source"; import { templateUsage } from "../entity/templateUsage"; import InternalException from "../exceptions/internalException"; import { UpdateTemplateUsageCommand } from "./templateUsageCommand"; export default abstract class TemplateUsageCommandHandler { /** * @description update templateUsage * @param UpdateTemplateUsageCommand * @returns {Promise} */ static async update(updateTemplateUsage: UpdateTemplateUsageCommand): Promise { return await dataSource .createQueryBuilder() .update(templateUsage) .set({ headerId: updateTemplateUsage.headerId, bodyId: updateTemplateUsage.bodyId, footerId: updateTemplateUsage.footerId, }) .where("scope = :scope", { scope: updateTemplateUsage.scope }) .execute() .then(() => {}) .catch((err) => { throw new InternalException("Failed updating templateUsage", err); }); } }