exodus-framework 2.0.747 → 2.0.749
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 +51 -7
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAAA,OAAO,
|
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,MAAM,cAAc,CAAC;AAGzE,eAAO,MAAM,SAAS,WAYpB,CAAC;AAEH,eAAO,MAAM,QAAQ,WAYnB,CAAC;AAgFH,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"}
|
package/lib/utils/database.js
CHANGED
@@ -77,6 +77,42 @@ function processCondition(cond) {
|
|
77
77
|
}
|
78
78
|
return simpleWhere;
|
79
79
|
}
|
80
|
+
function processDateCondition(key, cond) {
|
81
|
+
const simpleWhere = [key, undefined];
|
82
|
+
if (cond.eq !== undefined) {
|
83
|
+
simpleWhere[0] = _sequelize.Op.and;
|
84
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) = '${cond.eq}'`)];
|
85
|
+
}
|
86
|
+
if (cond.gt !== undefined) {
|
87
|
+
simpleWhere[0] = _sequelize.Op.and;
|
88
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) > '${cond.gt}'`)];
|
89
|
+
}
|
90
|
+
if (cond.lt !== undefined) {
|
91
|
+
simpleWhere[0] = _sequelize.Op.and;
|
92
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) < '${cond.lt}'`)];
|
93
|
+
}
|
94
|
+
if (cond.between !== undefined) {
|
95
|
+
simpleWhere[1] = {
|
96
|
+
[_sequelize.Op.between]: cond.notBetween.map(d => new Date(d))
|
97
|
+
};
|
98
|
+
}
|
99
|
+
if (cond.notBetween !== undefined) {
|
100
|
+
simpleWhere[1] = {
|
101
|
+
[_sequelize.Op.notBetween]: cond.notBetween.map(d => new Date(d))
|
102
|
+
};
|
103
|
+
}
|
104
|
+
if (cond.in !== undefined) {
|
105
|
+
simpleWhere[1] = {
|
106
|
+
[_sequelize.Op.in]: cond.notBetween.map(d => new Date(d))
|
107
|
+
};
|
108
|
+
}
|
109
|
+
if (cond.notIn !== undefined) {
|
110
|
+
simpleWhere[1] = {
|
111
|
+
[_sequelize.Op.notIn]: cond.notBetween.map(d => new Date(d))
|
112
|
+
};
|
113
|
+
}
|
114
|
+
return simpleWhere;
|
115
|
+
}
|
80
116
|
|
81
117
|
// Função Principal para Processar Filtros
|
82
118
|
function processFilters(filters) {
|
@@ -98,14 +134,22 @@ function processFilters(filters) {
|
|
98
134
|
where[logicalOp].push(...t);
|
99
135
|
} else {
|
100
136
|
const field = key;
|
101
|
-
const
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
137
|
+
const isDate = condition.type && condition.type === 'DATE';
|
138
|
+
const isTime = condition.type && condition.type === 'TIME';
|
139
|
+
const isDateTime = condition.type && condition.type === 'DATETIME';
|
140
|
+
if (isDate) {
|
141
|
+
const [k, c] = processDateCondition(key, condition);
|
142
|
+
where[k] = c;
|
107
143
|
} else {
|
108
|
-
|
144
|
+
const processedCondition = processCondition(condition);
|
145
|
+
if (where[field]) {
|
146
|
+
where[field] = {
|
147
|
+
...where[field],
|
148
|
+
...processedCondition
|
149
|
+
};
|
150
|
+
} else {
|
151
|
+
where[field] = processedCondition;
|
152
|
+
}
|
109
153
|
}
|
110
154
|
}
|
111
155
|
});
|