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