feat(base): add deleteMany service method for batch row delete

This commit is contained in:
Philipinho
2026-04-18 16:31:11 +01:00
parent 4a9e891582
commit a7f9d66778
@@ -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<void> {
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,