c2-mongoose 2.1.314 → 2.1.315

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.
@@ -250,12 +250,12 @@ var SearcherFlow = /** @class */ (function () {
250
250
  }
251
251
  else if (key.endsWith("AtLeastOneExists")) {
252
252
  key = key.replace("AtLeastOneExists", "");
253
- var lastField = key.split('.').pop();
254
- if (!lastField)
253
+ var fields = key.split('.');
254
+ if (!fields)
255
255
  return condition;
256
256
  // const elemMatch = {} as any
257
257
  // elemMatch[lastField] = value as boolean
258
- condition[key] = { $elemMatch: (_a = {}, _a[lastField] = value, _a) };
258
+ condition[fields[0]] = { $elemMatch: (_a = {}, _a[fields[1]] = value, _a) };
259
259
  }
260
260
  else {
261
261
  if (((_d = (_c = (_b = this.model) === null || _b === void 0 ? void 0 : _b.schema) === null || _c === void 0 ? void 0 : _c.paths[key]) === null || _d === void 0 ? void 0 : _d.instance) === 'Array') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.314",
3
+ "version": "2.1.315",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -225,12 +225,12 @@ class SearcherFlow<D> {
225
225
  } else if (key.endsWith("AtLeastOneExists")) {
226
226
  key = key.replace("AtLeastOneExists", "");
227
227
 
228
- const lastField = key.split('.').pop()
229
- if (!lastField) return condition;
228
+ const fields = key.split('.')
229
+ if (!fields) return condition;
230
230
 
231
231
  // const elemMatch = {} as any
232
232
  // elemMatch[lastField] = value as boolean
233
- condition[key] = { $elemMatch: { [lastField]: value as boolean} }
233
+ condition[fields[0]] = { $elemMatch: { [fields[1]]: value as boolean} }
234
234
  } else {
235
235
  if (this.model?.schema?.paths[key]?.instance === 'Array') {
236
236
  if (!Array.isArray(value)) {