pangea-server 3.3.118 → 3.3.119
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/dist/database/db.class.js +4 -18
- package/package.json +1 -1
|
@@ -304,38 +304,24 @@ function getFinalOrder(order, config = {}) {
|
|
|
304
304
|
});
|
|
305
305
|
return [...finalOrder, ...(!config.attributes ? [['createdAt', 'DESC']] : [])];
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function processJsonInstance(model, jsonInstance) {
|
|
308
308
|
for (const [relName] of Object.entries(model.Relations)) {
|
|
309
309
|
const relInstance = jsonInstance[relName];
|
|
310
310
|
if (!relInstance)
|
|
311
311
|
continue;
|
|
312
312
|
const relModel = model.Relations[relName].getModelFn();
|
|
313
313
|
if (Array.isArray(relInstance)) {
|
|
314
|
-
jsonInstance[relName] = relInstance.map((relIns) =>
|
|
314
|
+
jsonInstance[relName] = relInstance.map((relIns) => processJsonInstance(relModel, relIns));
|
|
315
315
|
}
|
|
316
316
|
else {
|
|
317
|
-
jsonInstance[relName] =
|
|
317
|
+
jsonInstance[relName] = processJsonInstance(relModel, relInstance);
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
model.InitInstance(jsonInstance);
|
|
321
321
|
return jsonInstance;
|
|
322
322
|
}
|
|
323
323
|
function processInstance(model, instance) {
|
|
324
|
-
|
|
325
|
-
for (const [relName] of Object.entries(model.Relations)) {
|
|
326
|
-
const relInstance = jsonInstance[relName];
|
|
327
|
-
if (!relInstance)
|
|
328
|
-
continue;
|
|
329
|
-
const relModel = model.Relations[relName].getModelFn();
|
|
330
|
-
if (Array.isArray(relInstance)) {
|
|
331
|
-
jsonInstance[relName] = relInstance.map((relIns) => processRelInstance(relModel, relIns));
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
jsonInstance[relName] = processRelInstance(relModel, relInstance);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
model.InitInstance(jsonInstance);
|
|
338
|
-
return jsonInstance;
|
|
324
|
+
return processJsonInstance(model, instance.toJSON());
|
|
339
325
|
}
|
|
340
326
|
function processInstances(model, instances) {
|
|
341
327
|
return instances.map((instance) => processInstance(model, instance));
|