evaengine 1.0.1 → 1.0.2
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/package.json
CHANGED
package/src/entities/index.js
CHANGED
|
@@ -22,7 +22,7 @@ Sequelize.prototype.validateIsUnique = (col, msg) => {
|
|
|
22
22
|
.keys(schema)
|
|
23
23
|
.filter(field => schema[field].primaryKey)
|
|
24
24
|
.forEach((pk) => {
|
|
25
|
-
conditions.where[pk] = {
|
|
25
|
+
conditions.where[pk] = { [Sequelize.Op.ne]: self[pk] };
|
|
26
26
|
});
|
|
27
27
|
}).then(() =>
|
|
28
28
|
self.Model.count(conditions).then((found) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import constitute from 'constitute';
|
|
2
2
|
import crypto from 'crypto';
|
|
3
|
-
import util from 'util';
|
|
4
3
|
import moment from 'moment-timezone';
|
|
5
4
|
import Logger from '../services/logger.js';
|
|
6
5
|
import Cache from '../services/cache.js';
|
|
@@ -65,7 +64,7 @@ export const requestToCacheKey = (req, hashStrategy) => {
|
|
|
65
64
|
*/
|
|
66
65
|
function ViewCacheMiddleware(cache, logger) {
|
|
67
66
|
return (options = {}) => {
|
|
68
|
-
if (
|
|
67
|
+
if (options === null || typeof options !== 'object') {
|
|
69
68
|
options = {
|
|
70
69
|
ttl: options
|
|
71
70
|
};
|
package/src/swagger/index.js
CHANGED
|
@@ -433,7 +433,8 @@ export class ExSwagger {
|
|
|
433
433
|
const source = await fs.readFileSync(file);
|
|
434
434
|
try {
|
|
435
435
|
acorn.parse(source, {
|
|
436
|
-
ecmaVersion:
|
|
436
|
+
ecmaVersion: 'latest',
|
|
437
|
+
sourceType: 'module',
|
|
437
438
|
allowImportExportEverywhere: true,
|
|
438
439
|
onComment: comments
|
|
439
440
|
});
|
package/src/utils/smart_query.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import moment from 'moment-timezone';
|
|
2
|
+
import { Op } from 'sequelize';
|
|
2
3
|
import { InvalidArgumentException } from '../exceptions/index.js';
|
|
3
4
|
|
|
5
|
+
const OPERATORS = {
|
|
6
|
+
$eq: Op.eq,
|
|
7
|
+
$like: Op.like,
|
|
8
|
+
$in: Op.in,
|
|
9
|
+
$notIn: Op.notIn,
|
|
10
|
+
$gte: Op.gte,
|
|
11
|
+
$lte: Op.lte
|
|
12
|
+
};
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* 自动根据 req.query 生成 sequelize 查询条件, 自动判断参数清单中是否有值
|
|
6
16
|
*/
|
|
@@ -265,7 +275,7 @@ export default class SmartQuery {
|
|
|
265
275
|
criteria.order = this.order;
|
|
266
276
|
}
|
|
267
277
|
|
|
268
|
-
if (
|
|
278
|
+
if (Object.keys(this.where).length > 0) {
|
|
269
279
|
criteria.where = this.where;
|
|
270
280
|
}
|
|
271
281
|
|
|
@@ -311,7 +321,7 @@ export default class SmartQuery {
|
|
|
311
321
|
if (!Object.keys(this.where).includes(filedName)) {
|
|
312
322
|
this.where[filedName] = {};
|
|
313
323
|
}
|
|
314
|
-
this.where[filedName][predicate] = value;
|
|
324
|
+
this.where[filedName][OPERATORS[predicate] || predicate] = value;
|
|
315
325
|
}
|
|
316
326
|
|
|
317
327
|
/**
|