mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
⚡ Add support for dot-notation in mode "mergeByKey" for Merge-Node
This commit is contained in:
parent
b7eab083e8
commit
3c8946ba7d
|
@ -1,3 +1,5 @@
|
|||
import { get } from 'lodash';
|
||||
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
GenericValue,
|
||||
|
@ -148,8 +150,6 @@ export class Merge implements INodeType {
|
|||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
// const itemsInput2 = this.getInputData(1);
|
||||
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const mode = this.getNodeParameter('mode', 0) as string;
|
||||
|
@ -264,25 +264,26 @@ export class Merge implements INodeType {
|
|||
} = {};
|
||||
let entry: INodeExecutionData;
|
||||
for (entry of dataInput2) {
|
||||
if (!entry.json || !entry.json.hasOwnProperty(propertyName2)) {
|
||||
const key = get(entry.json, propertyName2);
|
||||
if (!entry.json || !key) {
|
||||
// Entry does not have the property so skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
copyData[entry.json[propertyName2] as string] = entry;
|
||||
copyData[key as string] = entry;
|
||||
}
|
||||
|
||||
// Copy data on entries
|
||||
let referenceValue: GenericValue;
|
||||
let key: string;
|
||||
for (entry of dataInput1) {
|
||||
referenceValue = get(entry.json, propertyName1);
|
||||
|
||||
if (!entry.json || !entry.json.hasOwnProperty(propertyName1)) {
|
||||
if (!referenceValue) {
|
||||
// Entry does not have the property so skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
referenceValue = entry.json[propertyName1];
|
||||
|
||||
if (!['string', 'number'].includes(typeof referenceValue)) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue