exodus-framework 2.0.9996 → 2.0.9997
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.
- package/lib/utils/database.d.ts.map +1 -1
- package/lib/utils/database.js +23 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIzF,eAAO,MAAM,MAAM,WASjB,CAAC;AAqGH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACnF,YAAY,CAAC,CAAC,CAAC,CAwCjB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,EAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,iBAalD"}
|
package/lib/utils/database.js
CHANGED
@@ -9,6 +9,7 @@ exports.processFilters = processFilters;
|
|
9
9
|
var _sequelize = require("sequelize");
|
10
10
|
var _core = _interopRequireDefault(require("../app/core"));
|
11
11
|
var _error = require("../app/error");
|
12
|
+
var _dateFns = require("date-fns");
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
14
|
const mainDb = exports.mainDb = new _sequelize.Sequelize({
|
14
15
|
database: _core.default.settings.getDatabase().main.database,
|
@@ -78,9 +79,26 @@ function processDateCondition(key, cond) {
|
|
78
79
|
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) < '${cond.lt}'`)];
|
79
80
|
}
|
80
81
|
if (cond.between !== undefined) {
|
82
|
+
const start = cond.between[0];
|
83
|
+
const end = cond.between[1];
|
84
|
+
|
85
|
+
// console.log(start, end);
|
86
|
+
|
87
|
+
let startDate = (0, _dateFns.parseISO)(start);
|
88
|
+
if ((0, _dateFns.isValid)(startDate) && !hasTime(start)) {
|
89
|
+
// console.log('Ajustando início do dia');
|
90
|
+
startDate = (0, _dateFns.startOfDay)(startDate);
|
91
|
+
}
|
92
|
+
let endDate = (0, _dateFns.parseISO)(end);
|
93
|
+
if ((0, _dateFns.isValid)(endDate) && !hasTime(end)) {
|
94
|
+
// console.log('Ajustando fim do dia');
|
95
|
+
endDate = (0, _dateFns.endOfDay)(endDate);
|
96
|
+
}
|
81
97
|
simpleWhere[1] = {
|
82
|
-
[_sequelize.Op.between]:
|
98
|
+
[_sequelize.Op.between]: [startDate, endDate]
|
83
99
|
};
|
100
|
+
|
101
|
+
// console.log('Condição entre processada:', simpleWhere[1]);
|
84
102
|
}
|
85
103
|
if (cond.notBetween !== undefined) {
|
86
104
|
simpleWhere[1] = {
|
@@ -154,4 +172,8 @@ async function InsertIndexes(context, tableName, indexes) {
|
|
154
172
|
console.log('tentativa de adicionar index falhou');
|
155
173
|
}
|
156
174
|
}
|
175
|
+
}
|
176
|
+
function hasTime(str) {
|
177
|
+
const timeRegex = /\b\d{1,2}:\d{2}(:\d{2})?\b/;
|
178
|
+
return timeRegex.test(str);
|
157
179
|
}
|