@autofleet/sadot 0.6.3-beta.2 → 0.6.4-beta.1
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
|
@@ -26,7 +26,7 @@ export declare const customFieldsSortScope: (name: string) => (sort: CustomField
|
|
|
26
26
|
order?: undefined;
|
|
27
27
|
} | {
|
|
28
28
|
attributes: {
|
|
29
|
-
include: import("sequelize/types/utils").Literal[];
|
|
29
|
+
include: (string | import("sequelize/types/utils").Literal)[][];
|
|
30
30
|
};
|
|
31
31
|
order: import("sequelize/types/utils").Literal[];
|
|
32
32
|
};
|
package/dist/scopes/filter.js
CHANGED
|
@@ -57,17 +57,24 @@ const customFieldsSortScope = (name) => (sort) => {
|
|
|
57
57
|
if (!sort || sort.length === 0) {
|
|
58
58
|
return {};
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
const includes = Object.entries(sort).map(([key]) => ([
|
|
61
|
+
sequelize_typescript_1.Sequelize.literal(`(
|
|
62
|
+
SELECT custom_fields->>'${key}'
|
|
63
|
+
FROM (
|
|
64
|
+
SELECT
|
|
65
|
+
cv.model_id,
|
|
66
|
+
jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
67
|
+
FROM custom_field_values AS cv
|
|
68
|
+
INNER JOIN custom_field_definitions AS cd
|
|
69
|
+
ON cv.custom_field_definition_id = cd.id
|
|
70
|
+
AND cd.model_type = '${name}'
|
|
71
|
+
WHERE cv.model_id = "${name}"."id"
|
|
72
|
+
GROUP BY cv.model_id
|
|
73
|
+
) AS CustomFieldAggregation
|
|
74
|
+
)`),
|
|
75
|
+
`customFields_${key}`,
|
|
76
|
+
]));
|
|
77
|
+
const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields_${key}" ${value}`));
|
|
71
78
|
return {
|
|
72
79
|
attributes: {
|
|
73
80
|
include: includes,
|
package/package.json
CHANGED
package/src/scopes/filter.ts
CHANGED
|
@@ -82,20 +82,26 @@ export const customFieldsSortScope = (
|
|
|
82
82
|
if (!sort || sort.length === 0) {
|
|
83
83
|
return {};
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
console.log('sort', sort);
|
|
87
|
-
console.log('name', name);
|
|
88
|
-
console.log('Object.entries(sort)', Object.entries(sort));
|
|
89
85
|
const includes = Object.entries(sort).map(([key]) =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
([
|
|
87
|
+
Sequelize.literal(`(
|
|
88
|
+
SELECT custom_fields->>'${key}'
|
|
89
|
+
FROM (
|
|
90
|
+
SELECT
|
|
91
|
+
cv.model_id,
|
|
92
|
+
jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
93
|
+
FROM custom_field_values AS cv
|
|
94
|
+
INNER JOIN custom_field_definitions AS cd
|
|
95
|
+
ON cv.custom_field_definition_id = cd.id
|
|
96
|
+
AND cd.model_type = '${name}'
|
|
97
|
+
WHERE cv.model_id = "${name}"."id"
|
|
98
|
+
GROUP BY cv.model_id
|
|
99
|
+
) AS CustomFieldAggregation
|
|
100
|
+
)`),
|
|
101
|
+
`customFields_${key}`,
|
|
102
|
+
]));
|
|
98
103
|
|
|
104
|
+
const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields_${key}" ${value}`));
|
|
99
105
|
return {
|
|
100
106
|
attributes: {
|
|
101
107
|
include: includes,
|