spice-js 2.6.53 → 2.6.54

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.
@@ -19,8 +19,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
19
19
 
20
20
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
21
21
 
22
- global.mapping_dept = "*";
23
-
24
22
  var co = require("co");
25
23
 
26
24
  var regeneratorRuntime = require("regenerator-runtime");
@@ -37,7 +35,8 @@ var SDate = require("sonover-date"),
37
35
  _external_modifier_loaded = Symbol(),
38
36
  _skip_cache = Symbol(),
39
37
  _serializers = Symbol(),
40
- _level = Symbol(); //const _type = Symbol("type");
38
+ _level = Symbol(),
39
+ _mapping_dept = Symbol(); //const _type = Symbol("type");
41
40
 
42
41
 
43
42
  var that;
@@ -59,20 +58,21 @@ class SpiceModel {
59
58
  }
60
59
 
61
60
  try {
62
- var _args$args, _args2, _args2$args, _args3, _args3$args, _args4, _args4$args;
61
+ var _args2, _args2$args, _args$args, _args3, _args3$args, _args4, _args4$args, _args5, _args5$args;
63
62
 
64
63
  var dbtype = spice.config.database.connections[args.connection].type || "couchbase";
65
64
 
66
65
  var Database = require("spice-" + dbtype);
67
66
 
67
+ this[_mapping_dept] = ((_args2 = args) == null ? void 0 : (_args2$args = _args2.args) == null ? void 0 : _args2$args.mapping_dept) || 100;
68
68
  this.type = "";
69
69
  this.collection = args.connection;
70
70
  this[_args] = args.args;
71
71
  this[_external_modifier_loaded] = false;
72
72
  this[_disable_lifecycle_events] = ((_args$args = args.args) == null ? void 0 : _args$args.disable_lifecycle_events) || false;
73
- this[_ctx] = (_args2 = args) == null ? void 0 : (_args2$args = _args2.args) == null ? void 0 : _args2$args.ctx;
74
- this[_skip_cache] = ((_args3 = args) == null ? void 0 : (_args3$args = _args3.args) == null ? void 0 : _args3$args.skip_cache) || false;
75
- this[_level] = ((_args4 = args) == null ? void 0 : (_args4$args = _args4.args) == null ? void 0 : _args4$args._level) || 0;
73
+ this[_ctx] = (_args3 = args) == null ? void 0 : (_args3$args = _args3.args) == null ? void 0 : _args3$args.ctx;
74
+ this[_skip_cache] = ((_args4 = args) == null ? void 0 : (_args4$args = _args4.args) == null ? void 0 : _args4$args.skip_cache) || false;
75
+ this[_level] = ((_args5 = args) == null ? void 0 : (_args5$args = _args5.args) == null ? void 0 : _args5$args._level) || 0;
76
76
  this[_hooks] = {
77
77
  create: {
78
78
  before: [],
@@ -566,9 +566,7 @@ class SpiceModel {
566
566
 
567
567
  return _asyncToGenerator(function* () {
568
568
  try {
569
- var _args5;
570
-
571
- global.mapping_dept = ((_args5 = args) == null ? void 0 : _args5.mapping_dept) ? Number(args.mapping_dept) : global.mapping_dept;
569
+ if (args.mapping_dept) _this4[_mapping_dept] = args.mapping_dept;
572
570
 
573
571
  if (!args) {
574
572
  args = {};
@@ -993,9 +991,10 @@ class SpiceModel {
993
991
  }
994
992
 
995
993
  try {
996
- var _args6, _args7, _args8, _args9;
994
+ var _args6, _args7, _args8;
997
995
 
998
996
  args.columns = _this12.prepColumns(args.columns);
997
+ if (args.mapping_dept) _this12[_mapping_dept] = args.mapping_dept;
999
998
  var nestings = [..._this12.extractNestings((_args6 = args) == null ? void 0 : _args6.query, _this12.type), ..._this12.extractNestings((_args7 = args) == null ? void 0 : _args7.columns, _this12.type), ..._this12.extractNestings((_args8 = args) == null ? void 0 : _args8.sort, _this12.type)];
1000
999
 
1001
1000
  var mappedNestings = _.compact(_.uniq(nestings).map(nesting => {
@@ -1028,7 +1027,6 @@ class SpiceModel {
1028
1027
 
1029
1028
  args.limit = Number(args.limit) || undefined;
1030
1029
  args.offset = Number(args.offset) || 0;
1031
- global.mapping_dept = ((_args9 = args) == null ? void 0 : _args9.mapping_dept) ? Number(args.mapping_dept) : global.mapping_dept;
1032
1030
  args.sort = args.sort ? args.sort.split(",").map(item => item.includes(".") ? item : "`" + _this12.type + "`." + _this12.formatSortComponent(item)).join(",") : "`" + _this12.type + "`.created_at DESC";
1033
1031
 
1034
1032
  if (args.skip_hooks !== true) {
@@ -1158,7 +1156,9 @@ class SpiceModel {
1158
1156
  data = Array.of(data);
1159
1157
  }
1160
1158
 
1161
- if (_this15[_level] < global.mapping_dept || global.mapping_dept == "*") {
1159
+ _this15[_mapping_dept];
1160
+
1161
+ if (_this15[_level] + 1 < _this15[_mapping_dept]) {
1162
1162
  var classes = _.isArray(Class) ? Class : [Class];
1163
1163
  var ids = [];
1164
1164
 
@@ -1171,7 +1171,8 @@ class SpiceModel {
1171
1171
  var returned_all = yield Promise.allSettled(_.map(classes, obj => {
1172
1172
  return new obj(_extends({}, _this15[_args], {
1173
1173
  skip_cache: _this15[_skip_cache],
1174
- _level: _this15[_level] + 1
1174
+ _level: _this15[_level] + 1,
1175
+ mapping_dept: _this15[_mapping_dept]
1175
1176
  })).getMulti({
1176
1177
  skip_hooks: true,
1177
1178
  ids: ids
@@ -1205,7 +1206,7 @@ class SpiceModel {
1205
1206
  data = Array.of(data);
1206
1207
  }
1207
1208
 
1208
- if (_this16[_level] < global.mapping_dept || global.mapping_dept == "*") {
1209
+ if (_this16[_level] + 1 < _this16[_mapping_dept]) {
1209
1210
  var ids = [];
1210
1211
 
1211
1212
  _.each(data, result => {
@@ -1228,7 +1229,8 @@ class SpiceModel {
1228
1229
  var returned_all = yield Promise.allSettled(_.map(classes, obj => {
1229
1230
  return new obj(_extends({}, _this16[_args], {
1230
1231
  skip_cache: _this16[_skip_cache],
1231
- _level: _this16[_level] + 1
1232
+ _level: _this16[_level] + 1,
1233
+ mapping_dept: _this16[_mapping_dept]
1232
1234
  })).getMulti({
1233
1235
  skip_hooks: true,
1234
1236
  ids: ids
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.53",
3
+ "version": "2.6.54",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {