@optimiser/common 1.0.321 → 1.0.322

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.
@@ -1456,6 +1456,24 @@ function SyncUserInOtherCollection(options, db, callback, next) {
1456
1456
  }
1457
1457
  }
1458
1458
  exports.SyncUserInOtherCollection = SyncUserInOtherCollection;
1459
+ function GetObjectByString(o, s) {
1460
+ s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
1461
+ s = s.replace(/^\./, ''); // strip a leading dot
1462
+ var a = s.split('.');
1463
+ for (var i = 0, n = a.length; i < n; ++i) {
1464
+ var k = a[i];
1465
+ if (k in o) {
1466
+ if (o[k] != null)
1467
+ o = o[k];
1468
+ else
1469
+ o = '';
1470
+ }
1471
+ else {
1472
+ return '';
1473
+ }
1474
+ }
1475
+ return o;
1476
+ }
1459
1477
  //Build _LookupDataField before save
1460
1478
  function BuildLookupDataField(fieldSchema, updateObj, db) {
1461
1479
  return new Promise(function (resolve, reject) {
@@ -1529,8 +1547,8 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1529
1547
  if (fieldSchema.ExcludeLookupFieldsOnSearch && fieldSchema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == fieldSchema.LookupFields[j]; }).length != 0) {
1530
1548
  return "continue";
1531
1549
  }
1532
- if (fldLookupData_1[fieldSchema.LookupFields[j]] != undefined)
1533
- result += fldLookupData_1[fieldSchema.LookupFields[j]].toString() + ' ';
1550
+ if (GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]) != undefined)
1551
+ result += GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]).toString() + ' ';
1534
1552
  };
1535
1553
  for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1536
1554
  _loop_10(j);
@@ -1573,8 +1591,8 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1573
1591
  var lookupRecord = data[i];
1574
1592
  if (fieldSchema.LookupFields != undefined) {
1575
1593
  for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1576
- if (lookupRecord[fieldSchema.LookupFields[j]] != undefined)
1577
- result += lookupRecord[fieldSchema.LookupFields[j]].toString() + ' ';
1594
+ if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1595
+ result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1578
1596
  }
1579
1597
  }
1580
1598
  }
@@ -1599,8 +1617,8 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1599
1617
  var result = '';
1600
1618
  if (fieldSchema.LookupFields != undefined) {
1601
1619
  for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1602
- if (fldLookupData_1[fieldSchema.LookupFields[j]] != undefined)
1603
- result += fldLookupData_1[fieldSchema.LookupFields[j]].toString() + ' ';
1620
+ if (GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]) != undefined)
1621
+ result += GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]).toString() + ' ';
1604
1622
  }
1605
1623
  }
1606
1624
  updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
@@ -1652,8 +1670,8 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1652
1670
  var lookupRecord = data[i];
1653
1671
  if (fieldSchema.LookupFields != undefined) {
1654
1672
  for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1655
- if (lookupRecord[fieldSchema.LookupFields[j]] != undefined)
1656
- result += lookupRecord[fieldSchema.LookupFields[j]].toString() + ' ';
1673
+ if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1674
+ result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1657
1675
  }
1658
1676
  }
1659
1677
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.321",
3
+ "version": "1.0.322",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {