@recursyve/nestjs-data-filter 11.1.2 → 11.1.3
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.
|
@@ -229,9 +229,6 @@ let DataFilterRepository = class DataFilterRepository {
|
|
|
229
229
|
}
|
|
230
230
|
getSearchTranslationAttributes() {
|
|
231
231
|
var _a;
|
|
232
|
-
if (!this._config.getSearchableTranslationAttributes().length) {
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
232
|
const attributes = [];
|
|
236
233
|
const modelAttr = this._config.getSearchableTranslationAttributes();
|
|
237
234
|
attributes.push(...modelAttr.map(attribute => ({
|
|
@@ -8,4 +8,5 @@ export declare class JsonOrderRule extends OrderRule implements JsonRuleDefiniti
|
|
|
8
8
|
json: JsonConfig;
|
|
9
9
|
constructor(definition: BaseOrderRuleDefinition & JsonRuleDefinition);
|
|
10
10
|
getOrderOption(model: typeof M, context: OrderRuleContext): OrderItemColumn;
|
|
11
|
+
private getModelPath;
|
|
11
12
|
}
|
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonOrderRule = void 0;
|
|
4
4
|
const sequelize_1 = require("sequelize");
|
|
5
|
+
const sequelize_utils_1 = require("../../sequelize.utils");
|
|
5
6
|
const order_rule_1 = require("./order-rule");
|
|
6
7
|
class JsonOrderRule extends order_rule_1.OrderRule {
|
|
7
8
|
constructor(definition) {
|
|
8
9
|
super(definition);
|
|
9
10
|
}
|
|
10
11
|
getOrderOption(model, context) {
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const jsonPath = typeof this.json.path === "function" ? this.json.path(context) : this.json.path;
|
|
13
|
+
const modelPath = this.getModelPath(model);
|
|
14
|
+
return (0, sequelize_1.literal)(`UPPER(JSON_UNQUOTE(JSON_EXTRACT(${modelPath}, '$.${jsonPath}')))`);
|
|
15
|
+
}
|
|
16
|
+
getModelPath(model) {
|
|
17
|
+
if (this.path) {
|
|
18
|
+
return sequelize_utils_1.SequelizeUtils.getLiteralFullName(this.attribute, this.path);
|
|
19
|
+
}
|
|
20
|
+
return `\`${model.name}\`.\`${this.attribute}\``;
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
23
|
exports.JsonOrderRule = JsonOrderRule;
|
package/lib/sequelize.utils.js
CHANGED
|
@@ -268,14 +268,15 @@ class SequelizeUtils {
|
|
|
268
268
|
return model;
|
|
269
269
|
}
|
|
270
270
|
static findColumnFieldName(model, name) {
|
|
271
|
-
var _a;
|
|
271
|
+
var _a, _b;
|
|
272
272
|
const field = Object.keys(model.rawAttributes).find((key) => {
|
|
273
|
+
var _a;
|
|
273
274
|
if (key === name) {
|
|
274
275
|
return true;
|
|
275
276
|
}
|
|
276
|
-
return model.rawAttributes[key].field === name;
|
|
277
|
+
return ((_a = model.rawAttributes[key]) === null || _a === void 0 ? void 0 : _a.field) === name;
|
|
277
278
|
});
|
|
278
|
-
return (_a = model.rawAttributes[field].field) !== null &&
|
|
279
|
+
return (_b = (_a = model.rawAttributes[field]) === null || _a === void 0 ? void 0 : _a.field) !== null && _b !== void 0 ? _b : name;
|
|
279
280
|
}
|
|
280
281
|
static isColumnJson(model, name) {
|
|
281
282
|
var _a, _b;
|