feat(Data Table Node): Add Update, Upsert operations (no-changelog) (#18820)

This commit is contained in:
Charlie Kolb
2025-08-28 13:20:29 +02:00
committed by GitHub
parent 0347c32cd5
commit 1b743ae251
12 changed files with 241 additions and 59 deletions

View File

@@ -1066,7 +1066,9 @@ describe('dataStore', () => {
]);
// ASSERT
await expect(result).rejects.toThrow(new DataStoreValidationError('unknown column name'));
await expect(result).rejects.toThrow(
new DataStoreValidationError("unknown column name 'cWrong'"),
);
});
it('rejects a invalid date string to date column', async () => {

View File

@@ -15,14 +15,15 @@ import {
ListDataStoreRowsOptions,
MoveDataStoreColumnOptions,
UpdateDataStoreOptions,
UpdateDataStoreRowsOptions,
UpsertDataStoreRowsOptions,
Workflow,
} from 'n8n-workflow';
import { OwnershipService } from '@/services/ownership.service';
import { DataStoreService } from './data-store.service';
import { OwnershipService } from '@/services/ownership.service';
@Service()
export class DataStoreProxyService implements DataStoreProxyProvider {
constructor(
@@ -134,6 +135,10 @@ export class DataStoreProxyService implements DataStoreProxyProvider {
return await dataStoreService.insertRows(dataStoreId, projectId, rows, true);
},
async updateRows(options: UpdateDataStoreRowsOptions) {
return await dataStoreService.updateRow(dataStoreId, projectId, options, true);
},
async upsertRows(options: UpsertDataStoreRowsOptions) {
return await dataStoreService.upsertRows(dataStoreId, projectId, options, true);
},

View File

@@ -176,6 +176,12 @@ export class DataStoreService {
);
}
async updateRow<T extends boolean | undefined>(
dataStoreId: string,
projectId: string,
dto: Omit<UpdateDataStoreRowDto, 'returnData'>,
returnData?: T,
): Promise<T extends true ? DataStoreRowReturn[] : true>;
async updateRow(
dataStoreId: string,
projectId: string,
@@ -225,7 +231,12 @@ export class DataStoreService {
): void {
// Include system columns like 'id' if requested
const allColumns = includeSystemColumns
? [{ name: 'id', type: 'number' }, ...columns]
? [
{ name: 'id', type: 'number' },
{ name: 'createdAt', type: 'date' },
{ name: 'updatedAt', type: 'date' },
...columns,
]
: columns;
const columnNames = new Set(allColumns.map((x) => x.name));
const columnTypeMap = new Map(allColumns.map((x) => [x.name, x.type]));
@@ -236,7 +247,7 @@ export class DataStoreService {
}
for (const key of keys) {
if (!columnNames.has(key)) {
throw new DataStoreValidationError('unknown column name');
throw new DataStoreValidationError(`unknown column name '${key}'`);
}
this.validateCell(row, key, columnTypeMap);
}