c2-mongoose 2.1.274 → 2.1.275

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.
@@ -252,7 +252,7 @@ var SearcherFlow = /** @class */ (function () {
252
252
  if (value === 'false') {
253
253
  value = false;
254
254
  }
255
- if (key.endsWith('DateRange') || key.endsWith('DateTimeRange')) {
255
+ if (key.endsWith('DateRange')) {
256
256
  var fieldName = key.replace('Range', '');
257
257
  var values = value;
258
258
  if ((0, Utils_1.isNotEmpty)(values[0])) {
@@ -271,6 +271,25 @@ var SearcherFlow = /** @class */ (function () {
271
271
  }
272
272
  filters.$and.push(condition);
273
273
  }
274
+ else if (key.endsWith('DateTimeRange')) {
275
+ var fieldName = key.replace('Range', '');
276
+ var values = value;
277
+ if ((0, Utils_1.isNotEmpty)(values[0])) {
278
+ var momentValue = (0, moment_1.default)(values[0]);
279
+ // momentValue.hour(0)
280
+ // momentValue.minute(0)
281
+ // momentValue.second(0)
282
+ condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.tz('America/Sao_Paulo', true).toDate() });
283
+ }
284
+ if ((0, Utils_1.isNotEmpty)(values[1])) {
285
+ var momentValue = (0, moment_1.default)(values[1]);
286
+ // momentValue.hour(23)
287
+ // momentValue.minute(59)
288
+ // momentValue.second(59)
289
+ condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.tz('America/Sao_Paulo', true).toDate() });
290
+ }
291
+ filters.$and.push(condition);
292
+ }
274
293
  else if (key.endsWith('Like')) {
275
294
  var fieldName = key.replace('Like', '');
276
295
  condition[fieldName] = _this.buildRegex(value); //{ $regex: value as any, $options: 'i' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.274",
3
+ "version": "2.1.275",
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",
@@ -217,7 +217,7 @@ class SearcherFlow<D> {
217
217
  value = false
218
218
  }
219
219
 
220
- if (key.endsWith('DateRange') || key.endsWith('DateTimeRange')) {
220
+ if (key.endsWith('DateRange')) {
221
221
  var fieldName = key.replace('Range', '')
222
222
  var values = value as any
223
223
  if (isNotEmpty(values[0])) {
@@ -242,6 +242,31 @@ class SearcherFlow<D> {
242
242
  }
243
243
  }
244
244
  filters.$and.push(condition)
245
+ }else if (key.endsWith('DateTimeRange')) {
246
+ var fieldName = key.replace('Range', '')
247
+ var values = value as any
248
+ if (isNotEmpty(values[0])) {
249
+ var momentValue = moment(values[0])
250
+ // momentValue.hour(0)
251
+ // momentValue.minute(0)
252
+ // momentValue.second(0)
253
+ condition[fieldName] = {
254
+ ...condition[fieldName],
255
+ $gte: momentValue.tz('America/Sao_Paulo', true).toDate()
256
+ }
257
+ }
258
+
259
+ if (isNotEmpty(values[1])) {
260
+ var momentValue = moment(values[1])
261
+ // momentValue.hour(23)
262
+ // momentValue.minute(59)
263
+ // momentValue.second(59)
264
+ condition[fieldName] = {
265
+ ...condition[fieldName],
266
+ $lte: momentValue.tz('America/Sao_Paulo', true).toDate()
267
+ }
268
+ }
269
+ filters.$and.push(condition)
245
270
  } else if (key.endsWith('Like')) {
246
271
  var fieldName = key.replace('Like', '')
247
272
  condition[fieldName] = this.buildRegex(value as string) //{ $regex: value as any, $options: 'i' }