mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
feat(core): Use filters for delete data table rows (no-changelog) (#19375)
This commit is contained in:
@@ -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 }));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user