@infrab4a/connect 0.14.0 → 0.14.1-beta.0

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.
@@ -1578,20 +1578,23 @@
1578
1578
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1579
1579
  _this.makeFirestoreWhere = function (queryReference, filter) { return Object.keys(filter).reduce(function (query, fieldName) { return _this.buildWhereSentence(query, fieldName, filter[fieldName]); }, queryReference); };
1580
1580
  _this.buildWhereSentence = function (queryReference, fieldName, options) {
1581
+ var _b;
1581
1582
  if (_this.isSubCollection(_this) && fieldName === _this.parentIdField)
1582
1583
  return queryReference;
1584
+ var plainInstance = new _this.model((_b = {}, _b[fieldName] = options === null || options === void 0 ? void 0 : options.value, _b)).toPlain();
1585
+ var firestoreFieldName = Object.keys(plainInstance).find(function (key) { return plainInstance[key] === (options === null || options === void 0 ? void 0 : options.value); });
1583
1586
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.LIKE) {
1584
1587
  if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1585
- return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
1586
- queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
1587
- queryReference = queryReference.where(fieldName.toString(), '<=', options.value + "~");
1588
+ return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
1589
+ queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
1590
+ queryReference = queryReference.where(firestoreFieldName, '<=', options.value + "~");
1588
1591
  return queryReference;
1589
1592
  }
1590
1593
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1591
- return queryReference.where(fieldName.toString(), 'array-contains', options.value);
1594
+ return queryReference.where(firestoreFieldName, 'array-contains', options.value);
1592
1595
  if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value))
1593
1596
  return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName + "." + key, options[key]); }, queryReference);
1594
- return queryReference.where(fieldName.toString(), (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1597
+ return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1595
1598
  };
1596
1599
  return _this;
1597
1600
  }