c2-mongoose 2.1.274 → 2.1.276

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,26 @@ 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
+ var fieldName = key.replace('Range', '');
257
+ var values = value;
258
+ if ((0, Utils_1.isNotEmpty)(values[0])) {
259
+ var momentValue = (0, moment_1.default)(values[0]);
260
+ momentValue.hour(0);
261
+ momentValue.minute(0);
262
+ momentValue.second(0);
263
+ condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.tz('America/Sao_Paulo', true).toDate() });
264
+ }
265
+ if ((0, Utils_1.isNotEmpty)(values[1])) {
266
+ var momentValue = (0, moment_1.default)(values[1]);
267
+ momentValue.hour(23);
268
+ momentValue.minute(59);
269
+ momentValue.second(59);
270
+ condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.tz('America/Sao_Paulo', true).toDate() });
271
+ }
272
+ filters.$and.push(condition);
273
+ }
274
+ else if (key.endsWith('DateTimeRange')) {
256
275
  var fieldName = key.replace('Range', '');
257
276
  var values = value;
258
277
  if ((0, Utils_1.isNotEmpty)(values[0])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.274",
3
+ "version": "2.1.276",
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,32 @@ 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
+ var fieldName = key.replace('Range', '')
222
+ var values = value as any
223
+ if (isNotEmpty(values[0])) {
224
+ var momentValue = moment(values[0])
225
+ momentValue.hour(0)
226
+ momentValue.minute(0)
227
+ momentValue.second(0)
228
+ condition[fieldName] = {
229
+ ...condition[fieldName],
230
+ $gte: momentValue.tz('America/Sao_Paulo', true).toDate()
231
+ }
232
+ }
233
+
234
+ if (isNotEmpty(values[1])) {
235
+ var momentValue = moment(values[1])
236
+ momentValue.hour(23)
237
+ momentValue.minute(59)
238
+ momentValue.second(59)
239
+ condition[fieldName] = {
240
+ ...condition[fieldName],
241
+ $lte: momentValue.tz('America/Sao_Paulo', true).toDate()
242
+ }
243
+ }
244
+ filters.$and.push(condition)
245
+ }else if (key.endsWith('DateTimeRange')) {
221
246
  var fieldName = key.replace('Range', '')
222
247
  var values = value as any
223
248
  if (isNotEmpty(values[0])) {