c2-mongoose 2.1.335 → 2.1.337

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.
@@ -1,6 +1,6 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class GetHighestNumberFlow {
3
- exec(model: mongoose.Model<any>, field: string): Promise<any>;
3
+ exec(params: any, model: mongoose.Model<any>, field: string): Promise<any>;
4
4
  }
5
5
  declare const _default: GetHighestNumberFlow;
6
6
  export default _default;
@@ -35,17 +35,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
38
50
  Object.defineProperty(exports, "__esModule", { value: true });
51
+ var MatchFlowItem_1 = __importDefault(require("./item/MatchFlowItem"));
39
52
  var GetHighestNumberFlow = /** @class */ (function () {
40
53
  function GetHighestNumberFlow() {
41
54
  }
42
- GetHighestNumberFlow.prototype.exec = function (model, field) {
55
+ GetHighestNumberFlow.prototype.exec = function (params, model, field) {
43
56
  return __awaiter(this, void 0, void 0, function () {
44
57
  var result, highestCode;
45
58
  var _a;
46
59
  return __generator(this, function (_b) {
47
60
  switch (_b.label) {
48
- case 0: return [4 /*yield*/, model.aggregate([
61
+ case 0: return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.exec(params, model), true), [
49
62
  {
50
63
  $match: (_a = {},
51
64
  _a[field] = { $regex: '^[0-9]+$' } // Filtra apenas códigos numéricos válidos
@@ -58,7 +71,7 @@ var GetHighestNumberFlow = /** @class */ (function () {
58
71
  maxCode: { $max: { $toInt: "$".concat(field) } }
59
72
  }
60
73
  }
61
- ])];
74
+ ], false))];
62
75
  case 1:
63
76
  result = _b.sent();
64
77
  highestCode = result.length > 0 ? result[0].maxCode : 0;
@@ -87,7 +87,12 @@ var SearcherV2Flow = /** @class */ (function () {
87
87
  {
88
88
  $facet: facet
89
89
  }
90
- ], false))];
90
+ ], false), {
91
+ collation: {
92
+ locale: "pt",
93
+ numericOrdering: true
94
+ }
95
+ })];
91
96
  case 1:
92
97
  result = _c.sent();
93
98
  ret = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.335",
3
+ "version": "2.1.337",
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",
@@ -1,8 +1,10 @@
1
1
  import mongoose from "mongoose";
2
+ import MatchFlowItem from "./item/MatchFlowItem";
2
3
 
3
4
  class GetHighestNumberFlow {
4
- async exec(model: mongoose.Model<any>, field: string) {
5
+ async exec(params: any, model: mongoose.Model<any>, field: string) {
5
6
  const result = await model.aggregate([
7
+ ...MatchFlowItem.exec(params, model),
6
8
  {
7
9
  $match: {
8
10
  [field]: { $regex: '^[0-9]+$' } // Filtra apenas códigos numéricos válidos
@@ -50,7 +50,12 @@ class SearcherV2Flow {
50
50
  {
51
51
  $facet: facet
52
52
  }
53
- ])
53
+ ], {
54
+ collation: {
55
+ locale: "pt",
56
+ numericOrdering: true
57
+ }
58
+ })
54
59
 
55
60
  const ret: any = {}
56
61
  ret.items = result[0].items