From a7c519f0b711ad5b326e14354c1ec646cdde5e73 Mon Sep 17 00:00:00 2001 From: JeffreySyrinx <130656264+JeffreySyrinx@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:20:35 +0200 Subject: [PATCH 1/2] eqJoin now supports joining an array of data per item in collection --- src/lokijs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lokijs.js b/src/lokijs.js index 0588569c..c3ac504e 100644 --- a/src/lokijs.js +++ b/src/lokijs.js @@ -4050,10 +4050,17 @@ }; } + var temp = []; + //Run map function over each object in the resultset for (var j = 0; j < leftDataLength; j++) { key = leftKeyisFunction ? leftJoinKey(leftData[j]) : leftData[j][leftJoinKey]; - result.push(mapFun(leftData[j], joinMap[key] || {})); + for( var k = 0; k < key.length; k++ ) + { + temp.push( joinMap[key[k]] ); + } + result.push(mapFun(leftData[j], temp || {})); + temp = []; } //return return a new resultset with no filters From c6b9a97292d7f9b646b00d1c5ccc7d90637e95ab Mon Sep 17 00:00:00 2001 From: JeffreySyrinx <130656264+JeffreySyrinx@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:22:21 +0200 Subject: [PATCH 2/2] Update eqJoin --- src/lokijs.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lokijs.js b/src/lokijs.js index c3ac504e..2a02dacf 100644 --- a/src/lokijs.js +++ b/src/lokijs.js @@ -4050,19 +4050,17 @@ }; } - var temp = []; - + var data = []; //Run map function over each object in the resultset for (var j = 0; j < leftDataLength; j++) { key = leftKeyisFunction ? leftJoinKey(leftData[j]) : leftData[j][leftJoinKey]; for( var k = 0; k < key.length; k++ ) { - temp.push( joinMap[key[k]] ); + data.push( joinMap[key[k]] ); } - result.push(mapFun(leftData[j], temp || {})); - temp = []; + result.push(mapFun(leftData[j], data || {})); + data = []; } - //return return a new resultset with no filters this.collection = new Collection('joinData'); this.collection.insert(result);