@autofleet/sadot 0.6.5 → 0.6.6
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/dist/scopes/filter.d.ts +1 -1
- package/dist/scopes/filter.js +18 -11
- package/package.json +1 -1
- package/src/scopes/filter.ts +18 -12
package/dist/scopes/filter.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const customFieldsSortScope: (name: string) => (sort: CustomField
|
|
|
30
30
|
order?: undefined;
|
|
31
31
|
} | {
|
|
32
32
|
attributes: {
|
|
33
|
-
include: import("sequelize/types/utils").Literal[];
|
|
33
|
+
include: (string | import("sequelize/types/utils").Literal)[][];
|
|
34
34
|
};
|
|
35
35
|
order: import("sequelize/types/utils").Literal[];
|
|
36
36
|
};
|
package/dist/scopes/filter.js
CHANGED
|
@@ -73,17 +73,24 @@ const customFieldsSortScope = (name) => (sort) => {
|
|
|
73
73
|
if (!sort || sort.length === 0) {
|
|
74
74
|
return {};
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
const includes = Object.entries(sort).map(([key]) => ([
|
|
77
|
+
sequelize_typescript_1.Sequelize.literal(`(
|
|
78
|
+
SELECT custom_fields->>'${key}'
|
|
79
|
+
FROM (
|
|
80
|
+
SELECT
|
|
81
|
+
cv.model_id,
|
|
82
|
+
jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
83
|
+
FROM custom_field_values AS cv
|
|
84
|
+
INNER JOIN custom_field_definitions AS cd
|
|
85
|
+
ON cv.custom_field_definition_id = cd.id
|
|
86
|
+
AND cd.model_type = '${name}'
|
|
87
|
+
WHERE cv.model_id = "${name}"."id"
|
|
88
|
+
GROUP BY cv.model_id
|
|
89
|
+
) AS CustomFieldAggregation
|
|
90
|
+
)`),
|
|
91
|
+
`customFields_${key}`,
|
|
92
|
+
]));
|
|
93
|
+
const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields_${key}" ${value}`));
|
|
87
94
|
return {
|
|
88
95
|
attributes: {
|
|
89
96
|
include: includes,
|
package/package.json
CHANGED
package/src/scopes/filter.ts
CHANGED
|
@@ -101,20 +101,26 @@ export const customFieldsSortScope = (
|
|
|
101
101
|
if (!sort || sort.length === 0) {
|
|
102
102
|
return {};
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
console.log('sort', sort);
|
|
106
|
-
console.log('name', name);
|
|
107
|
-
console.log('Object.entries(sort)', Object.entries(sort));
|
|
108
104
|
const includes = Object.entries(sort).map(([key]) =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
105
|
+
([
|
|
106
|
+
Sequelize.literal(`(
|
|
107
|
+
SELECT custom_fields->>'${key}'
|
|
108
|
+
FROM (
|
|
109
|
+
SELECT
|
|
110
|
+
cv.model_id,
|
|
111
|
+
jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
112
|
+
FROM custom_field_values AS cv
|
|
113
|
+
INNER JOIN custom_field_definitions AS cd
|
|
114
|
+
ON cv.custom_field_definition_id = cd.id
|
|
115
|
+
AND cd.model_type = '${name}'
|
|
116
|
+
WHERE cv.model_id = "${name}"."id"
|
|
117
|
+
GROUP BY cv.model_id
|
|
118
|
+
) AS CustomFieldAggregation
|
|
119
|
+
)`),
|
|
120
|
+
`customFields_${key}`,
|
|
121
|
+
]));
|
|
117
122
|
|
|
123
|
+
const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields_${key}" ${value}`));
|
|
118
124
|
return {
|
|
119
125
|
attributes: {
|
|
120
126
|
include: includes,
|