mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import {
|
|
NodeOperationError,
|
|
type IDisplayOptions,
|
|
type IExecuteFunctions,
|
|
type INodeExecutionData,
|
|
type INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
import { makeAddRow, getAddRow } from '../../common/addRow';
|
|
import { getSelectFields, getSelectFilter } from '../../common/selectMany';
|
|
import { getDataTableProxyExecute } from '../../common/utils';
|
|
|
|
export const FIELD: string = 'update';
|
|
|
|
const displayOptions: IDisplayOptions = {
|
|
show: {
|
|
resource: ['row'],
|
|
operation: [FIELD],
|
|
},
|
|
};
|
|
|
|
export const description: INodeProperties[] = [
|
|
...getSelectFields(displayOptions),
|
|
makeAddRow(FIELD, displayOptions),
|
|
];
|
|
|
|
export async function execute(
|
|
this: IExecuteFunctions,
|
|
index: number,
|
|
): Promise<INodeExecutionData[]> {
|
|
const dataStoreProxy = await getDataTableProxyExecute(this, index);
|
|
|
|
const row = getAddRow(this, index);
|
|
const filter = getSelectFilter(this, index);
|
|
|
|
if (filter.filters.length === 0) {
|
|
throw new NodeOperationError(this.getNode(), 'At least one condition is required');
|
|
}
|
|
|
|
const updatedRows = await dataStoreProxy.updateRows({
|
|
data: row,
|
|
filter,
|
|
});
|
|
|
|
return updatedRows.map((json) => ({ json }));
|
|
}
|