mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-03 10:17:00 +02:00
PR Feedback
This commit is contained in:
parent
d5fe75300a
commit
2999b6be88
|
|
@ -50,11 +50,24 @@ export class DataStore implements INodeType {
|
|||
|
||||
methods = {
|
||||
listSearch: {
|
||||
async tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||
// @ADO-3904: Pagination here does not work until a filter is entered or removed, suspected bug in ResourceLocator
|
||||
async tableSearch(
|
||||
this: ILoadOptionsFunctions,
|
||||
filterString?: string,
|
||||
prevPaginationToken?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
if (this.helpers.getDataStoreAggregateProxy === undefined) return { results: [] };
|
||||
|
||||
const proxy = await this.helpers.getDataStoreAggregateProxy();
|
||||
const result = await proxy.getManyAndCount({ take: 1000000 });
|
||||
|
||||
const skip = prevPaginationToken === undefined ? 0 : parseInt(prevPaginationToken, 10);
|
||||
const take = 100;
|
||||
const filter =
|
||||
filterString === undefined ? {} : { filter: { name: filterString.toLowerCase() } };
|
||||
const result = await proxy.getManyAndCount({
|
||||
skip,
|
||||
take,
|
||||
...filter,
|
||||
});
|
||||
|
||||
const results = result.data.map((row) => {
|
||||
return {
|
||||
|
|
@ -63,8 +76,11 @@ export class DataStore implements INodeType {
|
|||
};
|
||||
});
|
||||
|
||||
const paginationToken = results.length === take ? `${skip + take}` : undefined;
|
||||
|
||||
return {
|
||||
results,
|
||||
paginationToken,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import type { INodeProperties } from 'n8n-workflow';
|
|||
|
||||
import * as get from './get.operation';
|
||||
import * as insert from './insert.operation';
|
||||
import { DATA_STORE_ID_FIELD } from '../../common/fields';
|
||||
|
||||
export { insert, get };
|
||||
|
||||
|
|
@ -50,6 +51,30 @@ export const description: INodeProperties[] = [
|
|||
],
|
||||
default: 'insert',
|
||||
},
|
||||
{
|
||||
displayName: 'Data Store',
|
||||
name: DATA_STORE_ID_FIELD,
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
typeOptions: {
|
||||
searchListMethod: 'tableSearch',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
displayOptions: { show: { resource: ['row'] } },
|
||||
},
|
||||
|
||||
...insert.description,
|
||||
...get.description,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export async function execute(
|
|||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const dataStoreProxy = await getDataStoreProxy(this, index);
|
||||
// todo: pagination
|
||||
const response = await dataStoreProxy.getManyRowsAndCount({});
|
||||
return (response?.data ?? []).map((json) => ({ json }));
|
||||
return response.data.map((json) => ({ json }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import {
|
||||
OperationalError,
|
||||
type IDisplayOptions,
|
||||
type IDataObject,
|
||||
type IExecuteFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodeProperties,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { COLUMNS } from '../../common/fields';
|
||||
|
|
@ -48,7 +48,7 @@ export async function execute(
|
|||
const success = await dataStoreProxy.insertRows([data as never]);
|
||||
|
||||
if (!success) {
|
||||
throw new OperationalError('Failed to insert record into data store');
|
||||
throw new NodeOperationError(this.getNode(), 'Failed to insert record into data store');
|
||||
}
|
||||
|
||||
return [{ json: data }];
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ import {
|
|||
import { DATA_STORE_ID_FIELD } from './fields';
|
||||
|
||||
export async function getDataStoreProxy(
|
||||
ef: IExecuteFunctions,
|
||||
ctx: IExecuteFunctions,
|
||||
i: number,
|
||||
): Promise<IDataStoreProjectService> {
|
||||
if (ef.helpers.getDataStoreProxy === undefined)
|
||||
if (ctx.helpers.getDataStoreProxy === undefined)
|
||||
throw new UserError('Attempted to use Data Store node but the module is disabled');
|
||||
|
||||
const dataStoreId = ef.getNodeParameter(DATA_STORE_ID_FIELD, i, '', {
|
||||
const dataStoreId = ctx.getNodeParameter(DATA_STORE_ID_FIELD, i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
return await ef.helpers.getDataStoreProxy(dataStoreId);
|
||||
return await ctx.helpers.getDataStoreProxy(dataStoreId);
|
||||
}
|
||||
|
||||
export async function getDataStoreAggregateProxy(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user