c2-mongoose 2.1.421 → 2.1.423

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.
@@ -18,7 +18,7 @@ var BuildConditionSearchTextFlowItem = /** @class */ (function () {
18
18
  var regex = BuildRegexFlowItem_1.default.exec(filters.searchText);
19
19
  for (var _i = 0, camposString_1 = camposString; _i < camposString_1.length; _i++) {
20
20
  var fieldString = camposString_1[_i];
21
- if (((_a = model.schema.path(fieldString)) === null || _a === void 0 ? void 0 : _a.instance) === "ObjectId") {
21
+ if (fieldString.endsWith("_id") || ((_a = model.schema.path(fieldString)) === null || _a === void 0 ? void 0 : _a.instance) === "ObjectId") {
22
22
  var conditionAux_1 = {};
23
23
  conditionAux_1["$expr"] = {
24
24
  "$regexMatch": {
@@ -30,7 +30,7 @@ var PopulateFlowItem = /** @class */ (function () {
30
30
  if (!fieldDefinition)
31
31
  return;
32
32
  var typeFirst = fieldDefinition.instance;
33
- if (typeFirst === 'Array') {
33
+ if (typeFirst === 'Array' && (rest === null || rest === void 0 ? void 0 : rest.length)) {
34
34
  populateClauses = __spreadArray(__spreadArray([], populateClauses, true), LookupArrayFlowItem_1.default.execute(first, rest, populateClauses, modelRoot), true);
35
35
  return;
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.421",
3
+ "version": "2.1.423",
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",
@@ -14,7 +14,7 @@ class BuildConditionSearchTextFlowItem {
14
14
 
15
15
  for (let fieldString of camposString) {
16
16
 
17
- if (model.schema.path(fieldString)?.instance === "ObjectId") {
17
+ if ((fieldString as string).endsWith("_id") || model.schema.path(fieldString)?.instance === "ObjectId") {
18
18
  let conditionAux: { [key: string]: any } = {}
19
19
  conditionAux["$expr"] = {
20
20
  "$regexMatch": {
@@ -19,7 +19,7 @@ class PopulateFlowItem {
19
19
 
20
20
  let typeFirst = fieldDefinition.instance
21
21
 
22
- if (typeFirst === 'Array') {
22
+ if (typeFirst === 'Array' && rest?.length) {
23
23
  populateClauses = [...populateClauses, ...LookupArrayFlowItem.execute(first, rest, populateClauses, modelRoot)]
24
24
  return
25
25
  }