c2-mongoose 2.1.281 → 2.1.283

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.
@@ -238,16 +238,16 @@ var SearcherFlow = /** @class */ (function () {
238
238
  var values = value;
239
239
  if ((0, Utils_1.isNotEmpty)(values[0])) {
240
240
  var momentValue = (0, moment_1.default)(values[0]);
241
- momentValue.hour(0);
242
- momentValue.minute(0);
243
- momentValue.second(0);
241
+ // momentValue.hour(0)
242
+ // momentValue.minute(0)
243
+ // momentValue.second(0)
244
244
  condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.tz('America/Sao_Paulo', true).toDate() });
245
245
  }
246
246
  if ((0, Utils_1.isNotEmpty)(values[1])) {
247
247
  var momentValue = (0, moment_1.default)(values[1]);
248
- momentValue.hour(23);
249
- momentValue.minute(59);
250
- momentValue.second(59);
248
+ // momentValue.hour(23)
249
+ // momentValue.minute(59)
250
+ // momentValue.second(59)
251
251
  condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.tz('America/Sao_Paulo', true).toDate() });
252
252
  }
253
253
  }
@@ -304,7 +304,7 @@ var SearcherFlow = /** @class */ (function () {
304
304
  var _this = this;
305
305
  // Recuperar todos os campos do tipo String
306
306
  var camposString = (0, Utils_1.isEmpty)(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields;
307
- var filters = { $and: [], $or: [] };
307
+ var filters = { $and: [] };
308
308
  Object.entries(objectSearch).forEach(function (_a) {
309
309
  var key = _a[0], value = _a[1];
310
310
  if ((0, Utils_1.isNotEmpty)(value) || value === null) {
@@ -358,22 +358,27 @@ var SearcherFlow = /** @class */ (function () {
358
358
  if (filters.$and.length === 0)
359
359
  delete filters['$and'];
360
360
  if (objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or) {
361
- Object.entries(objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or).forEach(function (_a) {
362
- var key = _a[0], value = _a[1];
363
- if ((0, Utils_1.isEmpty)(value))
364
- return;
365
- if (typeof value === 'string' && _this.isValidObjectId(value) && key !== 'owner') {
366
- value = new mongoose_1.Types.ObjectId(value);
367
- }
368
- if (value === 'true') {
369
- value = true;
370
- }
371
- if (value === 'false') {
372
- value = false;
373
- }
374
- var condition = _this.buildCondition(key, value);
375
- filters.$or.push(condition);
376
- });
361
+ for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
362
+ var clause = _c[_b];
363
+ if (!filters.$or)
364
+ filters.$or = [];
365
+ Object.entries(clause).forEach(function (_a) {
366
+ var key = _a[0], value = _a[1];
367
+ if ((0, Utils_1.isEmpty)(value))
368
+ return;
369
+ if (typeof value === 'string' && _this.isValidObjectId(value) && key !== 'owner') {
370
+ value = new mongoose_1.Types.ObjectId(value);
371
+ }
372
+ if (value === 'true') {
373
+ value = true;
374
+ }
375
+ if (value === 'false') {
376
+ value = false;
377
+ }
378
+ var condition = _this.buildCondition(key, value);
379
+ filters.$or.push(condition);
380
+ });
381
+ }
377
382
  }
378
383
  return filters;
379
384
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.281",
3
+ "version": "2.1.283",
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",
@@ -211,9 +211,9 @@ class SearcherFlow<D> {
211
211
  var values = value as any
212
212
  if (isNotEmpty(values[0])) {
213
213
  var momentValue = moment(values[0])
214
- momentValue.hour(0)
215
- momentValue.minute(0)
216
- momentValue.second(0)
214
+ // momentValue.hour(0)
215
+ // momentValue.minute(0)
216
+ // momentValue.second(0)
217
217
  condition[fieldName] = {
218
218
  ...condition[fieldName],
219
219
  $gte: momentValue.tz('America/Sao_Paulo', true).toDate()
@@ -222,9 +222,9 @@ class SearcherFlow<D> {
222
222
 
223
223
  if (isNotEmpty(values[1])) {
224
224
  var momentValue = moment(values[1])
225
- momentValue.hour(23)
226
- momentValue.minute(59)
227
- momentValue.second(59)
225
+ // momentValue.hour(23)
226
+ // momentValue.minute(59)
227
+ // momentValue.second(59)
228
228
  condition[fieldName] = {
229
229
  ...condition[fieldName],
230
230
  $lte: momentValue.tz('America/Sao_Paulo', true).toDate()
@@ -285,7 +285,7 @@ class SearcherFlow<D> {
285
285
  const camposString = isEmpty(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields
286
286
 
287
287
 
288
- let filters = { $and: [], $or: [] } as any
288
+ let filters = { $and: [] } as any
289
289
  Object.entries(objectSearch).forEach(([key, value]) => {
290
290
  if (isNotEmpty(value) || value === null) {
291
291
  if ([
@@ -344,24 +344,29 @@ class SearcherFlow<D> {
344
344
  delete filters['$and']
345
345
 
346
346
  if (objectSearch?.or) {
347
- Object.entries(objectSearch?.or).forEach(([key, value]) => {
348
- if (isEmpty(value)) return
349
-
350
- if (typeof value === 'string' && this.isValidObjectId(value as string) && key !== 'owner') {
351
- value = new Types.ObjectId(value as string)
352
- }
353
-
354
- if (value === 'true') {
355
- value = true
356
- }
357
-
358
- if (value === 'false') {
359
- value = false
360
- }
347
+ for (const clause of objectSearch?.or) {
348
+ if (!filters.$or) filters.$or = []
349
+
350
+ Object.entries(clause).forEach(([key, value]) => {
351
+
352
+ if (isEmpty(value)) return
361
353
 
362
- const condition = this.buildCondition(key, value)
363
- filters.$or.push(condition)
364
- })
354
+ if (typeof value === 'string' && this.isValidObjectId(value as string) && key !== 'owner') {
355
+ value = new Types.ObjectId(value as string)
356
+ }
357
+
358
+ if (value === 'true') {
359
+ value = true
360
+ }
361
+
362
+ if (value === 'false') {
363
+ value = false
364
+ }
365
+
366
+ const condition = this.buildCondition(key, value)
367
+ filters.$or.push(condition)
368
+ })
369
+ }
365
370
  }
366
371
 
367
372