Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ export class RecordOpenApiService {
return snapshots[0].data;
}

@retryOnDeadlock()
async deleteRecord(tableId: string, recordId: string, windowId?: string) {
return this.recordModifyService.deleteRecord(tableId, recordId, windowId);
}

@retryOnDeadlock()
async deleteRecords(tableId: string, recordIds: string[], windowId?: string) {
return this.recordModifyService.deleteRecords(tableId, recordIds, windowId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common';
import { generateOperationId } from '@teable/core';
import { PrismaService } from '@teable/db-main-prisma';
import { ClsService } from 'nestjs-cls';
import type { IThresholdConfig } from '../../../configs/threshold.config';
import { ThresholdConfig } from '../../../configs/threshold.config';
import { EventEmitterService } from '../../../event-emitter/event-emitter.service';
import { Events } from '../../../event-emitter/events';
import type { IClsStore } from '../../../types/cls';
Expand All @@ -19,7 +21,8 @@ export class RecordDeleteService {
private readonly eventEmitterService: EventEmitterService,
private readonly computedOrchestrator: ComputedOrchestratorService,
private readonly tableDomainQueryService: TableDomainQueryService,
private readonly cls: ClsService<IClsStore>
private readonly cls: ClsService<IClsStore>,
@ThresholdConfig() private readonly thresholdConfig: IThresholdConfig
) {}

async deleteRecord(tableId: string, recordId: string, windowId?: string) {
Expand All @@ -29,7 +32,8 @@ export class RecordDeleteService {

async deleteRecords(tableId: string, recordIds: string[], windowId?: string) {
const table = await this.tableDomainQueryService.getTableDomainById(tableId);
const { records: recordsForEvent, orders } = await this.prismaService.$tx(async () => {
const { records: recordsForEvent, orders } = await this.prismaService.$tx(
async () => {
// Use a base-table query to ensure link values are derived from junction tables.
const recordsForEvent = await this.recordService.getRecordsById(
tableId,
Expand Down Expand Up @@ -71,7 +75,9 @@ export class RecordDeleteService {
});

return { records: recordsForEvent, orders };
});
},
{ timeout: this.thresholdConfig.bigTransactionTimeout }
);

this.eventEmitterService.emitAsync(Events.OPERATION_RECORDS_DELETE, {
operationId: generateOperationId(),
Expand Down
Loading