@resolveio/server-lib 4.6.0 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/methods/report-builder.js +26 -22
- package/package.json +1 -1
|
@@ -241,24 +241,28 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
241
241
|
var _a, _b;
|
|
242
242
|
if (row.field.includes('$')) {
|
|
243
243
|
var fieldData = row.field.split('.$');
|
|
244
|
-
var
|
|
244
|
+
var fieldPath_1 = '';
|
|
245
245
|
for (var i = 0; i < fieldData.length - 1; i++) {
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
query.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
246
|
+
fieldPath_1 += fieldData[i];
|
|
247
|
+
if (fieldPath_1.split('.$')[fieldPath_1.split('.$').length - 1].includes('(Lookup)')) {
|
|
248
|
+
if (!query.some(function (a) { return a.$lookup && a.$lookup.as === row.treeItem.lookup_as.replace(/\.\$/g, ''); })) {
|
|
249
|
+
query.push({ $lookup: {
|
|
250
|
+
from: row.treeItem.lookup_collection,
|
|
251
|
+
localField: row.treeItem.lookup_local_key,
|
|
252
|
+
foreignField: row.treeItem.lookup_foreign_key,
|
|
253
|
+
as: row.treeItem.lookup_as.replace(/\.\$/g, '')
|
|
254
|
+
} });
|
|
255
|
+
sizes.push(row.treeItem.lookup_as.replace(/\.\$\./g, '_'));
|
|
256
|
+
query.push({ $addFields: (_a = {}, _a['size_' + row.treeItem.lookup_as.replace(/\.\$\./g, '_')] = { $size: '$' + row.treeItem.lookup_as.replace(/\.\$/g, '') }, _a) });
|
|
257
|
+
query.push({ '$unwind': { path: '$' + row.treeItem.lookup_as.replace(/\.\$/g, ''), preserveNullAndEmptyArrays: true } });
|
|
258
|
+
}
|
|
257
259
|
}
|
|
258
260
|
else {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
if (!query.some(function (a) { return a.$addFields && Object.keys(a.$addFields).includes('size_' + fieldPath_1.replace(/\./g, '_')); })) {
|
|
262
|
+
sizes.push(fieldPath_1.replace(/\./g, '_'));
|
|
263
|
+
query.push({ $addFields: (_b = {}, _b['size_' + fieldPath_1.replace(/\./g, '_')] = { $size: '$' + fieldPath_1 }, _b) });
|
|
264
|
+
query.push({ '$unwind': { path: '$' + fieldPath_1, preserveNullAndEmptyArrays: true } });
|
|
265
|
+
}
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
}
|
|
@@ -268,10 +272,10 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
268
272
|
var _a, _b;
|
|
269
273
|
if (field.fieldPath.includes('$')) {
|
|
270
274
|
var fieldData = field.fieldPath.split('.$');
|
|
271
|
-
var
|
|
275
|
+
var fieldPath_2 = '';
|
|
272
276
|
for (var i = 0; i < fieldData.length - 1; i++) {
|
|
273
|
-
|
|
274
|
-
if (
|
|
277
|
+
fieldPath_2 += fieldData[i];
|
|
278
|
+
if (fieldPath_2.split('.$')[fieldPath_2.split('.$').length - 1].includes('(Lookup)')) {
|
|
275
279
|
if (!query.some(function (a) { return a.$lookup && a.$lookup.as === field.lookup_as.replace(/\.\$/g, ''); })) {
|
|
276
280
|
query.push({ $lookup: {
|
|
277
281
|
from: field.lookup_collection,
|
|
@@ -285,10 +289,10 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
else {
|
|
288
|
-
if (!query.some(function (a) { return a.$addFields && Object.keys(a.$addFields).includes('size_' +
|
|
289
|
-
sizes.push(
|
|
290
|
-
query.push({ $addFields: (_b = {}, _b['size_' +
|
|
291
|
-
query.push({ '$unwind': { path: '$' +
|
|
292
|
+
if (!query.some(function (a) { return a.$addFields && Object.keys(a.$addFields).includes('size_' + fieldPath_2.replace(/\./g, '_')); })) {
|
|
293
|
+
sizes.push(fieldPath_2.replace(/\./g, '_'));
|
|
294
|
+
query.push({ $addFields: (_b = {}, _b['size_' + fieldPath_2.replace(/\./g, '_')] = { $size: '$' + fieldPath_2 }, _b) });
|
|
295
|
+
query.push({ '$unwind': { path: '$' + fieldPath_2, preserveNullAndEmptyArrays: true } });
|
|
292
296
|
}
|
|
293
297
|
}
|
|
294
298
|
}
|