spice-js 2.6.8 → 2.6.10
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 +1 -15
- package/package.json +1 -1
- package/src/bootstrap/cache.js +14 -12
- package/src/models/SpiceModel.js +11 -22
|
@@ -929,10 +929,8 @@ class SpiceModel {
|
|
|
929
929
|
|
|
930
930
|
results = _cached_results2 == null ? void 0 : _cached_results2.value;
|
|
931
931
|
var shouleForceRefresh = yield _this11.shouldForceRefresh(_cached_results2);
|
|
932
|
-
console.log("Cache Results", _this11.type, (_cached_results2 == null ? void 0 : _cached_results2.value) == undefined, shouleForceRefresh, (_cached_results2 == null ? void 0 : _cached_results2.value) == undefined || shouleForceRefresh);
|
|
933
932
|
|
|
934
933
|
if ((_cached_results2 == null ? void 0 : _cached_results2.value) == undefined || shouleForceRefresh) {
|
|
935
|
-
console.log("Getting From Database With Cache", _this11.type);
|
|
936
934
|
results = yield _this11.database.search(_this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent);
|
|
937
935
|
|
|
938
936
|
_this11.getCacheProviderObject(_this11.type).set(key, {
|
|
@@ -962,8 +960,7 @@ class SpiceModel {
|
|
|
962
960
|
console.log(e);
|
|
963
961
|
}
|
|
964
962
|
|
|
965
|
-
results.data = filterResultsByColumns(results.data, args.columns);
|
|
966
|
-
|
|
963
|
+
results.data = filterResultsByColumns(results.data, args.columns);
|
|
967
964
|
return results;
|
|
968
965
|
} catch (e) {
|
|
969
966
|
console.log(e.stack);
|
|
@@ -1044,16 +1041,6 @@ class SpiceModel {
|
|
|
1044
1041
|
data = Array.of(data);
|
|
1045
1042
|
}
|
|
1046
1043
|
|
|
1047
|
-
function log() {
|
|
1048
|
-
if (source_property === "entity") {
|
|
1049
|
-
for (var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1050
|
-
message[_key] = arguments[_key];
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
console.log(message);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
1044
|
var classes = _.isArray(Class) ? Class : [Class];
|
|
1058
1045
|
var ids = [];
|
|
1059
1046
|
|
|
@@ -1079,7 +1066,6 @@ class SpiceModel {
|
|
|
1079
1066
|
var result_found = _.find(ug, g => {
|
|
1080
1067
|
return g.id == result[source_property];
|
|
1081
1068
|
}) || {};
|
|
1082
|
-
log(result[source_property], result_found.id);
|
|
1083
1069
|
result[store_property] = result_found;
|
|
1084
1070
|
return result;
|
|
1085
1071
|
});
|
package/package.json
CHANGED
package/src/bootstrap/cache.js
CHANGED
|
@@ -4,18 +4,20 @@ async function connect() {
|
|
|
4
4
|
try {
|
|
5
5
|
spice.cache_providers = {};
|
|
6
6
|
spice.monitor = new Map();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
spice.config.cache.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
if (spice.config?.cache?.providers) {
|
|
8
|
+
for (let key of Object.keys(spice.config.cache?.providers || {})) {
|
|
9
|
+
spice.cache_providers[key] = new spice.config.cache.providers[key](
|
|
10
|
+
spice.config.cache.drivers[key] || {}
|
|
11
|
+
);
|
|
12
|
+
spice.cache_providers[key]
|
|
13
|
+
.initialize()
|
|
14
|
+
.then(() => {
|
|
15
|
+
console.log("Redis initialized successfully");
|
|
16
|
+
})
|
|
17
|
+
.catch((err) => {
|
|
18
|
+
console.error("Error initializing Redis:", err);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
} catch (e) {
|
|
21
23
|
console.log(e.stack);
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -188,12 +188,16 @@ export default class SpiceModel {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (this[_ctx]) {
|
|
191
|
-
|
|
192
|
-
this[_ctx]
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
if (this[_ctx]?.state?.process_fields) {
|
|
192
|
+
let returned = await new this[_ctx].state.process_fields().process(
|
|
193
|
+
this[_ctx],
|
|
194
|
+
data,
|
|
195
|
+
this.type
|
|
196
|
+
);
|
|
197
|
+
return returned;
|
|
198
|
+
} else {
|
|
199
|
+
return data;
|
|
200
|
+
}
|
|
197
201
|
}
|
|
198
202
|
return [];
|
|
199
203
|
}
|
|
@@ -484,6 +488,7 @@ export default class SpiceModel {
|
|
|
484
488
|
}
|
|
485
489
|
}
|
|
486
490
|
} catch (e) {
|
|
491
|
+
console.log(e.message, e);
|
|
487
492
|
throw e;
|
|
488
493
|
}
|
|
489
494
|
}
|
|
@@ -854,15 +859,7 @@ export default class SpiceModel {
|
|
|
854
859
|
let shouleForceRefresh = await this.shouldForceRefresh(
|
|
855
860
|
cached_results
|
|
856
861
|
);
|
|
857
|
-
console.log(
|
|
858
|
-
"Cache Results",
|
|
859
|
-
this.type,
|
|
860
|
-
cached_results?.value == undefined,
|
|
861
|
-
shouleForceRefresh,
|
|
862
|
-
cached_results?.value == undefined || shouleForceRefresh
|
|
863
|
-
);
|
|
864
862
|
if (cached_results?.value == undefined || shouleForceRefresh) {
|
|
865
|
-
console.log("Getting From Database With Cache", this.type);
|
|
866
863
|
results = await this.database.search(
|
|
867
864
|
this.type,
|
|
868
865
|
args.columns || "",
|
|
@@ -913,7 +910,6 @@ export default class SpiceModel {
|
|
|
913
910
|
console.log(e);
|
|
914
911
|
}
|
|
915
912
|
results.data = filterResultsByColumns(results.data, args.columns);
|
|
916
|
-
//console.log("Trimmed Results", trimmed_results);
|
|
917
913
|
return results;
|
|
918
914
|
} catch (e) {
|
|
919
915
|
console.log(e.stack);
|
|
@@ -975,12 +971,6 @@ export default class SpiceModel {
|
|
|
975
971
|
data = Array.of(data);
|
|
976
972
|
}
|
|
977
973
|
|
|
978
|
-
function log(...message) {
|
|
979
|
-
if (source_property === "entity") {
|
|
980
|
-
console.log(message);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
974
|
let classes = _.isArray(Class) ? Class : [Class];
|
|
985
975
|
|
|
986
976
|
let ids = [];
|
|
@@ -1016,7 +1006,6 @@ export default class SpiceModel {
|
|
|
1016
1006
|
_.find(ug, (g) => {
|
|
1017
1007
|
return g.id == result[source_property];
|
|
1018
1008
|
}) || {};
|
|
1019
|
-
log(result[source_property], result_found.id);
|
|
1020
1009
|
result[store_property] = result_found;
|
|
1021
1010
|
return result;
|
|
1022
1011
|
});
|