Copy data on execution only if needed

This commit is contained in:
Jan Oberhauser
2019-08-01 22:55:33 +02:00
parent a8f1f9c0ba
commit 1b59d7b886
20 changed files with 182 additions and 65 deletions

View File

@@ -395,13 +395,9 @@ export class Redis implements INodeType {
} else if (['delete', 'get', 'keys', 'set'].includes(operation)) {
const items = this.getInputData();
if (items.length === 0) {
items.push({ json: {} });
}
let item: INodeExecutionData;
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
item = items[itemIndex];
item = { json: {} };
if (operation === 'delete') {
const keyDelete = this.getNodeParameter('key', itemIndex) as string;
@@ -409,8 +405,6 @@ export class Redis implements INodeType {
const clientDel = util.promisify(client.del).bind(client);
// @ts-ignore
await clientDel(keyDelete);
resolve(this.prepareOutputData(items));
} else if (operation === 'get') {
const propertyName = this.getNodeParameter('propertyName', itemIndex) as string;
const keyGet = this.getNodeParameter('key', itemIndex) as string;
@@ -418,8 +412,6 @@ export class Redis implements INodeType {
const value = await getValue(client, keyGet, keyType);
set(item.json, propertyName, value);
resolve(this.prepareOutputData(items));
} else if (operation === 'keys') {
const keyPattern = this.getNodeParameter('keyPattern', itemIndex) as string;
@@ -439,18 +431,16 @@ export class Redis implements INodeType {
for (const keyName of keys) {
set(item.json, keyName, await promises[keyName]);
}
resolve(this.prepareOutputData(items));
} else if (operation === 'set') {
const keySet = this.getNodeParameter('key', itemIndex) as string;
const value = this.getNodeParameter('value', itemIndex) as string;
const keyType = this.getNodeParameter('keyType', itemIndex) as string;
await setValue(client, keySet, value, keyType);
resolve(this.prepareOutputData(items));
}
}
resolve(this.prepareOutputData(items));
}
});
});