import { Repository } from 'typeorm'; import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { InjectRepository } from '@nestjs/typeorm'; import { RemoveOrganizationBeneficiaryCommand } from '../commands'; import { Beneficiary } from '../beneficiary.entity'; @CommandHandler(RemoveOrganizationBeneficiaryCommand) export class RemoveOrganizationBeneficiaryHandler implements ICommandHandler { constructor( @InjectRepository(Beneficiary) private readonly repository: Repository ) {} public async execute({ id, ownerId }: RemoveOrganizationBeneficiaryCommand): Promise { await this.repository.delete({ id, ownerId }); } }