@azteam/express 1.2.483 → 1.2.484
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.
|
@@ -41,7 +41,7 @@ function _default() {
|
|
|
41
41
|
var options = _objectSpread({
|
|
42
42
|
limit: 20,
|
|
43
43
|
allowSearchFields: [],
|
|
44
|
-
allowSortFields: ['created_at', 'modified_at', 'status'],
|
|
44
|
+
allowSortFields: ['id', 'created_at', 'modified_at', 'status'],
|
|
45
45
|
allowSelectFields: null,
|
|
46
46
|
allowLimits: [20, 40, 80]
|
|
47
47
|
}, opts);
|
|
@@ -119,28 +119,32 @@ function _default() {
|
|
|
119
119
|
break;
|
|
120
120
|
case 24:
|
|
121
121
|
_lodash["default"].map(req.query, function (value, key) {
|
|
122
|
-
if (key
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
if (key === 'id') {
|
|
123
|
+
req.query._id = value;
|
|
124
|
+
} else {
|
|
125
|
+
if (key.endsWith('_start')) {
|
|
126
|
+
var newKey = key.replace('_start', '');
|
|
127
|
+
req.query[newKey] = _objectSpread(_objectSpread({}, req.query[newKey]), {}, {
|
|
128
|
+
$gte: value
|
|
129
|
+
});
|
|
130
|
+
} else if (key.endsWith('_end')) {
|
|
131
|
+
var _newKey = key.replace('_end', '');
|
|
132
|
+
req.query[_newKey] = _objectSpread(_objectSpread({}, req.query[_newKey]), {}, {
|
|
133
|
+
$lte: value
|
|
134
|
+
});
|
|
135
|
+
} else if (value.includes(',') && key !== 'keywords') {
|
|
136
|
+
req.query[key] = {
|
|
137
|
+
$in: value.split(',')
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (!options.allowSearchFields.includes(key)) {
|
|
141
|
+
throw new _error.ErrorException(_error.INVALID, [{
|
|
142
|
+
field: 'key',
|
|
143
|
+
message: "Not exists search ".concat(key),
|
|
144
|
+
actual: key,
|
|
145
|
+
expected: options.allowSearchFields
|
|
146
|
+
}]);
|
|
147
|
+
}
|
|
144
148
|
}
|
|
145
149
|
});
|
|
146
150
|
if (req.query.keywords) {
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export default function (opts = {}) {
|
|
|
27
27
|
const options = {
|
|
28
28
|
limit: 20,
|
|
29
29
|
allowSearchFields: [],
|
|
30
|
-
allowSortFields: ['created_at', 'modified_at', 'status'],
|
|
30
|
+
allowSortFields: ['id', 'created_at', 'modified_at', 'status'],
|
|
31
31
|
allowSelectFields: null,
|
|
32
32
|
allowLimits: [20, 40, 80],
|
|
33
33
|
...opts,
|
|
@@ -100,35 +100,39 @@ export default function (opts = {}) {
|
|
|
100
100
|
};
|
|
101
101
|
} else {
|
|
102
102
|
_.map(req.query, (value, key) => {
|
|
103
|
-
if (key
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
103
|
+
if (key === 'id') {
|
|
104
|
+
req.query._id = value;
|
|
105
|
+
} else {
|
|
106
|
+
if (key.endsWith('_start')) {
|
|
107
|
+
const newKey = key.replace('_start', '');
|
|
108
|
+
|
|
109
|
+
req.query[newKey] = {
|
|
110
|
+
...req.query[newKey],
|
|
111
|
+
$gte: value,
|
|
112
|
+
};
|
|
113
|
+
} else if (key.endsWith('_end')) {
|
|
114
|
+
const newKey = key.replace('_end', '');
|
|
115
|
+
|
|
116
|
+
req.query[newKey] = {
|
|
117
|
+
...req.query[newKey],
|
|
118
|
+
$lte: value,
|
|
119
|
+
};
|
|
120
|
+
} else if (value.includes(',') && key !== 'keywords') {
|
|
121
|
+
req.query[key] = {
|
|
122
|
+
$in: value.split(','),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!options.allowSearchFields.includes(key)) {
|
|
127
|
+
throw new ErrorException(INVALID, [
|
|
128
|
+
{
|
|
129
|
+
field: 'key',
|
|
130
|
+
message: `Not exists search ${key}`,
|
|
131
|
+
actual: key,
|
|
132
|
+
expected: options.allowSearchFields,
|
|
133
|
+
},
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
|