mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(Data Table Node): Add Delete operation (no-changelog) (#18785)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import {
|
||||
NodeOperationError,
|
||||
type IDisplayOptions,
|
||||
type IExecuteFunctions,
|
||||
type INodeProperties,
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
DataStoreRowReturn,
|
||||
IDataStoreProjectService,
|
||||
IDisplayOptions,
|
||||
IExecuteFunctions,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { FilterType } from './constants';
|
||||
@@ -98,3 +100,41 @@ export function getSelectFilter(ctx: IExecuteFunctions, index: number) {
|
||||
|
||||
return buildGetManyFilter(fields, matchType);
|
||||
}
|
||||
|
||||
export async function executeSelectMany(
|
||||
ctx: IExecuteFunctions,
|
||||
index: number,
|
||||
dataStoreProxy: IDataStoreProjectService,
|
||||
): Promise<Array<{ json: DataStoreRowReturn }>> {
|
||||
const filter = getSelectFilter(ctx, index);
|
||||
|
||||
let take = 1000;
|
||||
const result: Array<{ json: DataStoreRowReturn }> = [];
|
||||
let totalCount = undefined;
|
||||
do {
|
||||
const response = await dataStoreProxy.getManyRowsAndCount({
|
||||
skip: result.length,
|
||||
take,
|
||||
filter,
|
||||
});
|
||||
const data = response.data.map((json) => ({ json }));
|
||||
|
||||
// Optimize common path of <1000 results
|
||||
if (response.count === response.data.length) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (totalCount !== undefined && response.count !== totalCount) {
|
||||
throw new NodeOperationError(
|
||||
ctx.getNode(),
|
||||
'synchronization error: result count changed during pagination',
|
||||
);
|
||||
}
|
||||
totalCount = response.count;
|
||||
|
||||
result.push.apply(result, data);
|
||||
take = Math.min(take, response.count - result.length);
|
||||
} while (take > 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user