From a7f9d6677868e73087e57f5e984d116f680565b7 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:31:11 +0100 Subject: [PATCH] feat(base): add deleteMany service method for batch row delete --- .../core/base/services/base-row.service.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/server/src/core/base/services/base-row.service.ts b/apps/server/src/core/base/services/base-row.service.ts index 165aea9f..0ce49d14 100644 --- a/apps/server/src/core/base/services/base-row.service.ts +++ b/apps/server/src/core/base/services/base-row.service.ts @@ -13,6 +13,7 @@ import { CreateRowDto } from '../dto/create-row.dto'; import { UpdateRowDto, DeleteRowDto, + DeleteRowsDto, ListRowsDto, ReorderRowDto, } from '../dto/update-row.dto'; @@ -38,6 +39,7 @@ import { BaseRowDeletedEvent, BaseRowReorderedEvent, BaseRowUpdatedEvent, + BaseRowsDeletedEvent, } from '../events/base-events'; @Injectable() @@ -155,6 +157,34 @@ export class BaseRowService { this.eventEmitter.emit(EventName.BASE_ROW_DELETED, event); } + async deleteMany( + dto: DeleteRowsDto, + workspaceId: string, + userId?: string, + ): Promise { + const rows = await this.baseRowRepo.findByIds(dto.rowIds, { workspaceId }); + if (rows.length !== dto.rowIds.length) { + throw new NotFoundException('One or more rows not found'); + } + if (rows.some((r) => r.baseId !== dto.baseId)) { + throw new NotFoundException('Row does not belong to base'); + } + + await this.baseRowRepo.softDeleteMany(dto.rowIds, { + baseId: dto.baseId, + workspaceId, + }); + + const event: BaseRowsDeletedEvent = { + baseId: dto.baseId, + workspaceId, + actorId: userId ?? null, + requestId: dto.requestId ?? null, + rowIds: dto.rowIds, + }; + this.eventEmitter.emit(EventName.BASE_ROWS_DELETED, event); + } + async list( dto: ListRowsDto, pagination: PaginationOptions,