mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(Data Table Node): Add Update, Upsert operations (no-changelog) (#18820)
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user