spice-js 2.7.13 → 2.7.14
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/build/models/SpiceModel.js +17 -2
- package/package.json +1 -1
- package/src/models/SpiceModel.js +16 -2
|
@@ -791,7 +791,7 @@ class SpiceModel {
|
|
|
791
791
|
if ((cached_results == null ? void 0 : cached_results.value) === undefined || (yield _this6.shouldForceRefresh(cached_results))) {
|
|
792
792
|
results = yield _this6.database.multi_get(args.ids, {
|
|
793
793
|
keep_type: true,
|
|
794
|
-
columns: args.columns && args.columns.length > 0 && args.columns != "" ? [...args.columns, 'type'] : []
|
|
794
|
+
columns: args.columns && args.columns.length > 0 && args.columns != "" ? [..._this6.extractBaseColumns(args.columns), 'type'] : []
|
|
795
795
|
});
|
|
796
796
|
|
|
797
797
|
_this6.getCacheProviderObject(_this6.type).set(key, {
|
|
@@ -802,7 +802,7 @@ class SpiceModel {
|
|
|
802
802
|
} else {
|
|
803
803
|
results = yield _this6.database.multi_get(args.ids, {
|
|
804
804
|
keep_type: true,
|
|
805
|
-
columns: args.columns && args.columns.length > 0 && args.columns != "" ? [...args.columns, 'type'] : []
|
|
805
|
+
columns: args.columns && args.columns.length > 0 && args.columns != "" ? [..._this6.extractBaseColumns(args.columns), 'type'] : []
|
|
806
806
|
});
|
|
807
807
|
}
|
|
808
808
|
}
|
|
@@ -1989,6 +1989,21 @@ class SpiceModel {
|
|
|
1989
1989
|
that.addModifier(modifier);
|
|
1990
1990
|
});
|
|
1991
1991
|
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Extracts the first segment of each column path for database queries.
|
|
1994
|
+
* e.g., ["name", "permissions.permission"] → ["name", "permissions"]
|
|
1995
|
+
* @param {string[]} columns - Array of column paths
|
|
1996
|
+
* @returns {string[]} - Array of base column names (deduplicated)
|
|
1997
|
+
*/
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
extractBaseColumns(columns) {
|
|
2001
|
+
if (!columns || !Array.isArray(columns)) return columns;
|
|
2002
|
+
return [...new Set(columns.map(col => {
|
|
2003
|
+
var firstDot = col.indexOf('.');
|
|
2004
|
+
return firstDot > -1 ? col.substring(0, firstDot) : col;
|
|
2005
|
+
}))];
|
|
2006
|
+
}
|
|
1992
2007
|
/**
|
|
1993
2008
|
* Checks if a field is present in the columns string.
|
|
1994
2009
|
* Used to skip modifier execution when the field isn't requested.
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -684,7 +684,7 @@ export default class SpiceModel {
|
|
|
684
684
|
cached_results?.value === undefined ||
|
|
685
685
|
(await this.shouldForceRefresh(cached_results))
|
|
686
686
|
) {
|
|
687
|
-
results = await this.database.multi_get(args.ids, {keep_type:true, columns:args.columns && args.columns.length > 0 && args.columns != ""?[...args.columns, 'type']:[]});
|
|
687
|
+
results = await this.database.multi_get(args.ids, {keep_type:true, columns:args.columns && args.columns.length > 0 && args.columns != ""?[...this.extractBaseColumns(args.columns), 'type']:[]});
|
|
688
688
|
this.getCacheProviderObject(this.type).set(
|
|
689
689
|
key,
|
|
690
690
|
{ value: results, time: new Date().getTime() },
|
|
@@ -692,7 +692,7 @@ export default class SpiceModel {
|
|
|
692
692
|
);
|
|
693
693
|
}
|
|
694
694
|
} else {
|
|
695
|
-
results = await this.database.multi_get(args.ids, {keep_type:true, columns:args.columns && args.columns.length > 0 && args.columns != ""?[...args.columns, 'type']:[]});
|
|
695
|
+
results = await this.database.multi_get(args.ids, {keep_type:true, columns:args.columns && args.columns.length > 0 && args.columns != ""?[...this.extractBaseColumns(args.columns), 'type']:[]});
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
_.remove(results, (o) => o.type != this.type);
|
|
@@ -1813,6 +1813,20 @@ export default class SpiceModel {
|
|
|
1813
1813
|
});
|
|
1814
1814
|
}
|
|
1815
1815
|
|
|
1816
|
+
/**
|
|
1817
|
+
* Extracts the first segment of each column path for database queries.
|
|
1818
|
+
* e.g., ["name", "permissions.permission"] → ["name", "permissions"]
|
|
1819
|
+
* @param {string[]} columns - Array of column paths
|
|
1820
|
+
* @returns {string[]} - Array of base column names (deduplicated)
|
|
1821
|
+
*/
|
|
1822
|
+
extractBaseColumns(columns) {
|
|
1823
|
+
if (!columns || !Array.isArray(columns)) return columns;
|
|
1824
|
+
return [...new Set(columns.map(col => {
|
|
1825
|
+
const firstDot = col.indexOf('.');
|
|
1826
|
+
return firstDot > -1 ? col.substring(0, firstDot) : col;
|
|
1827
|
+
}))];
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1816
1830
|
/**
|
|
1817
1831
|
* Checks if a field is present in the columns string.
|
|
1818
1832
|
* Used to skip modifier execution when the field isn't requested.
|