spice-js 2.6.16 → 2.6.18
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.
|
@@ -847,11 +847,13 @@ class SpiceModel {
|
|
|
847
847
|
if (column == "meta().id") {
|
|
848
848
|
column = undefined;
|
|
849
849
|
} else if (!column.startsWith("`") && !column.endsWith("`")) {
|
|
850
|
+
"`" + column + "`";
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (column) {
|
|
850
854
|
if (!column.includes(".") && !column.startsWith(that.type)) {
|
|
851
|
-
column = "`" + that.type + "
|
|
855
|
+
column = "`" + that.type + "`." + column;
|
|
852
856
|
}
|
|
853
|
-
|
|
854
|
-
return column;
|
|
855
857
|
}
|
|
856
858
|
|
|
857
859
|
return column;
|
|
@@ -868,10 +870,15 @@ class SpiceModel {
|
|
|
868
870
|
if (columns && columns != "") {
|
|
869
871
|
columns = columns.replace(/`/g, "");
|
|
870
872
|
columns = columns.replace(/meta\(\)\.id/g, "id");
|
|
871
|
-
var columnList = columns.split(",")
|
|
873
|
+
var columnList = columns.split(",").map(column => {
|
|
874
|
+
//if colums has a . then remove the first part of the string
|
|
875
|
+
return column.includes(".") ? _.last(column.split(".")) : column;
|
|
876
|
+
}); // Convert comma-separated string to array
|
|
872
877
|
|
|
873
878
|
columnList.push("_permissions"); // Always include _permissions
|
|
874
879
|
|
|
880
|
+
columnList.push("_permissions_"); // Always include _permissions
|
|
881
|
+
|
|
875
882
|
columnList.push("id"); // Always include _permissions
|
|
876
883
|
|
|
877
884
|
return _.map(data, entry => _.pick(entry, columnList));
|
|
@@ -894,7 +901,7 @@ class SpiceModel {
|
|
|
894
901
|
|
|
895
902
|
var nestings = [...extractNestings((_args4 = args) == null ? void 0 : _args4.query, _this11.type), ...extractNestings((_args5 = args) == null ? void 0 : _args5.columns, _this11.type), ...extractNestings((_args6 = args) == null ? void 0 : _args6.sort, _this11.type)];
|
|
896
903
|
|
|
897
|
-
var mappedNestings = _.compact(_.map(nestings, nesting => {
|
|
904
|
+
var mappedNestings = _.compact(_.map(_.uniq(nestings), nesting => {
|
|
898
905
|
var prop = _this11.props[nesting];
|
|
899
906
|
|
|
900
907
|
if (prop) {
|
|
@@ -953,6 +960,20 @@ class SpiceModel {
|
|
|
953
960
|
|
|
954
961
|
if (!args.sort) {
|
|
955
962
|
args.sort = "`" + _this11.type + "`.created_at DESC";
|
|
963
|
+
} else {
|
|
964
|
+
var sort_array = args.sort.split(","); // check the first string in each item in the array to see if it contains a . if not then add the type
|
|
965
|
+
|
|
966
|
+
var new_sort_array = [];
|
|
967
|
+
|
|
968
|
+
for (var i = 0; i < sort_array.length; i++) {
|
|
969
|
+
if (!sort_array[i].includes(".")) {
|
|
970
|
+
new_sort_array.push("`" + _this11.type + "`.`" + sort_array[i] + "`");
|
|
971
|
+
} else {
|
|
972
|
+
new_sort_array.push(sort_array[i]);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
args.sort = _.join(new_sort_array, ",");
|
|
956
977
|
}
|
|
957
978
|
|
|
958
979
|
if (args.skip_hooks != true) {
|
|
@@ -1019,10 +1040,6 @@ class SpiceModel {
|
|
|
1019
1040
|
}
|
|
1020
1041
|
} else {
|
|
1021
1042
|
results = yield _this11.database.search(_this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
|
|
1022
|
-
|
|
1023
|
-
if (_this11.type == "user") {
|
|
1024
|
-
console.log("results from DB No Chache available", results);
|
|
1025
|
-
}
|
|
1026
1043
|
}
|
|
1027
1044
|
}
|
|
1028
1045
|
}
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -779,6 +779,7 @@ export default class SpiceModel {
|
|
|
779
779
|
return column.includes(".") ? _.last(column.split(".")) : column;
|
|
780
780
|
}); // Convert comma-separated string to array
|
|
781
781
|
columnList.push("_permissions"); // Always include _permissions
|
|
782
|
+
columnList.push("_permissions_"); // Always include _permissions
|
|
782
783
|
columnList.push("id"); // Always include _permissions
|
|
783
784
|
return _.map(data, (entry) => _.pick(entry, columnList));
|
|
784
785
|
}
|