feat(core): Use filters for delete data table rows (no-changelog) (#19375)

This commit is contained in:
Daria
2025-09-11 10:31:27 +03:00
committed by GitHub
parent 6dd7797c39
commit b147709189
14 changed files with 384 additions and 138 deletions

View File

@@ -7,7 +7,7 @@ import {
} from 'n8n-workflow';
import { DRY_RUN } from '../../common/fields';
import { executeSelectMany, getSelectFields } from '../../common/selectMany';
import { getSelectFields, getSelectFilter } from '../../common/selectMany';
import { getDataTableProxyExecute } from '../../common/utils';
// named `deleteRows` since `delete` is a reserved keyword
@@ -48,14 +48,14 @@ export async function execute(
);
}
const matches = await executeSelectMany(this, index, dataStoreProxy);
const filter = getSelectFilter(this, index);
if (!dryRun) {
const success = await dataStoreProxy.deleteRows(matches.map((x) => x.json.id));
if (!success) {
throw new NodeOperationError(this.getNode(), `failed to delete rows for index ${index}`);
}
if (dryRun) {
const { data: rowsToDelete } = await dataStoreProxy.getManyRowsAndCount({ filter });
return rowsToDelete.map((json) => ({ json }));
}
return matches;
const result = await dataStoreProxy.deleteRows({ filter });
return result.map((json) => ({ json }));
}

View File

@@ -125,7 +125,7 @@ export async function executeSelectMany(
const PAGE_SIZE = 1000;
const result: Array<{ json: DataStoreRowReturn }> = [];
const limit = ctx.getNodeParameter('limit', index, undefined);
const limit = ctx.getNodeParameter('limit', index, 0);
let expectedTotal: number | undefined;
let skip = 0;