mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Make it possible to return all matches in with GoogleSheet Lookup
This commit is contained in:
@@ -316,10 +316,11 @@ export class GoogleSheet {
|
||||
* @param {number} keyRowIndex Index of the row which contains the keys
|
||||
* @param {number} dataStartRowIndex Index of the first row which contains data
|
||||
* @param {ILookupValues[]} lookupValues The lookup values which decide what data to return
|
||||
* @param {boolean} [returnAllMatches] Returns all the found matches instead of only the first one
|
||||
* @returns {Promise<IDataObject[]>}
|
||||
* @memberof GoogleSheet
|
||||
*/
|
||||
async lookupValues(inputData: string[][], keyRowIndex: number, dataStartRowIndex: number, lookupValues: ILookupValues[]): Promise<IDataObject[]> {
|
||||
async lookupValues(inputData: string[][], keyRowIndex: number, dataStartRowIndex: number, lookupValues: ILookupValues[], returnAllMatches?: boolean): Promise<IDataObject[]> {
|
||||
const keys: string[] = [];
|
||||
|
||||
if (keyRowIndex < 0 || dataStartRowIndex < keyRowIndex || keyRowIndex >= inputData.length) {
|
||||
@@ -351,13 +352,18 @@ export class GoogleSheet {
|
||||
for (rowIndex = dataStartRowIndex; rowIndex < inputData.length; rowIndex++) {
|
||||
if (inputData[rowIndex][returnColumnIndex].toString() === lookupValue.lookupValue.toString()) {
|
||||
returnData.push(inputData[rowIndex]);
|
||||
continue lookupLoop;
|
||||
|
||||
if (returnAllMatches !== true) {
|
||||
continue lookupLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If value could not be found add an empty one that the order of
|
||||
// the returned items stays the same
|
||||
returnData.push([]);
|
||||
if (returnAllMatches !== true) {
|
||||
returnData.push([]);
|
||||
}
|
||||
}
|
||||
|
||||
return this.structureData(returnData, 1, keys, true);
|
||||
|
||||
Reference in New Issue
Block a user