spice-js 2.6.15 → 2.6.16
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/package.json +1 -1
- package/src/models/SpiceModel.js +21 -7
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -752,10 +752,12 @@ export default class SpiceModel {
|
|
|
752
752
|
if (column == "meta().id") {
|
|
753
753
|
column = undefined;
|
|
754
754
|
} else if (!column.startsWith("`") && !column.endsWith("`")) {
|
|
755
|
+
`\`${column}\``;
|
|
756
|
+
}
|
|
757
|
+
if (column) {
|
|
755
758
|
if (!column.includes(".") && !column.startsWith(that.type)) {
|
|
756
|
-
column = `\`${that.type}
|
|
759
|
+
column = `\`${that.type}\`.${column}`;
|
|
757
760
|
}
|
|
758
|
-
return column;
|
|
759
761
|
}
|
|
760
762
|
return column;
|
|
761
763
|
})
|
|
@@ -772,7 +774,10 @@ export default class SpiceModel {
|
|
|
772
774
|
if (columns && columns != "") {
|
|
773
775
|
columns = columns.replace(/`/g, "");
|
|
774
776
|
columns = columns.replace(/meta\(\)\.id/g, "id");
|
|
775
|
-
let columnList = columns.split(",")
|
|
777
|
+
let columnList = columns.split(",").map((column) => {
|
|
778
|
+
//if colums has a . then remove the first part of the string
|
|
779
|
+
return column.includes(".") ? _.last(column.split(".")) : column;
|
|
780
|
+
}); // Convert comma-separated string to array
|
|
776
781
|
columnList.push("_permissions"); // Always include _permissions
|
|
777
782
|
columnList.push("id"); // Always include _permissions
|
|
778
783
|
return _.map(data, (entry) => _.pick(entry, columnList));
|
|
@@ -795,7 +800,7 @@ export default class SpiceModel {
|
|
|
795
800
|
...extractNestings(args?.sort, this.type),
|
|
796
801
|
];
|
|
797
802
|
let mappedNestings = _.compact(
|
|
798
|
-
_.map(nestings, (nesting) => {
|
|
803
|
+
_.map(_.uniq(nestings), (nesting) => {
|
|
799
804
|
let prop = this.props[nesting];
|
|
800
805
|
if (prop) {
|
|
801
806
|
if (prop.map) {
|
|
@@ -853,6 +858,18 @@ export default class SpiceModel {
|
|
|
853
858
|
|
|
854
859
|
if (!args.sort) {
|
|
855
860
|
args.sort = `\`${this.type}\`.created_at DESC`;
|
|
861
|
+
} else {
|
|
862
|
+
let sort_array = args.sort.split(",");
|
|
863
|
+
// check the first string in each item in the array to see if it contains a . if not then add the type
|
|
864
|
+
let new_sort_array = [];
|
|
865
|
+
for (let i = 0; i < sort_array.length; i++) {
|
|
866
|
+
if (!sort_array[i].includes(".")) {
|
|
867
|
+
new_sort_array.push(`\`${this.type}\`.\`${sort_array[i]}\``);
|
|
868
|
+
} else {
|
|
869
|
+
new_sort_array.push(sort_array[i]);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
args.sort = _.join(new_sort_array, ",");
|
|
856
873
|
}
|
|
857
874
|
if (args.skip_hooks != true) {
|
|
858
875
|
await this.run_hook(this, "list", "before");
|
|
@@ -959,9 +976,6 @@ export default class SpiceModel {
|
|
|
959
976
|
args.statement_consistent,
|
|
960
977
|
args._join
|
|
961
978
|
);
|
|
962
|
-
if (this.type == "user") {
|
|
963
|
-
console.log("results from DB No Chache available", results);
|
|
964
|
-
}
|
|
965
979
|
}
|
|
966
980
|
}
|
|
967
981
|
}
|