pangea-server 3.3.96 → 3.3.98
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.
|
@@ -305,23 +305,19 @@ function getFinalOrder(order, config = {}) {
|
|
|
305
305
|
return [...finalOrder, ...(!config.attributes ? [['createdAt', 'DESC']] : [])];
|
|
306
306
|
}
|
|
307
307
|
function processInstance(model, instance) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
// } else {
|
|
322
|
-
// processInstance(relModel, relInstance);
|
|
323
|
-
// }
|
|
324
|
-
// }
|
|
308
|
+
for (const [relName] of Object.entries(model.Relations)) {
|
|
309
|
+
const relInstance = instance[relName];
|
|
310
|
+
if (!relInstance)
|
|
311
|
+
continue;
|
|
312
|
+
const relModel = model.Relations[relName].getModelFn();
|
|
313
|
+
if (Array.isArray(relInstance)) {
|
|
314
|
+
relInstance.forEach((instance) => processInstance(relModel, instance));
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
processInstance(relModel, relInstance);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
instance.init?.();
|
|
325
321
|
return instance.toJSON();
|
|
326
322
|
}
|
|
327
323
|
function processInstances(model, instances) {
|
|
@@ -21,6 +21,7 @@ export declare abstract class BaseModel extends Model {
|
|
|
21
21
|
private static __Relations?;
|
|
22
22
|
id: ModelId;
|
|
23
23
|
version: NonAttribute<number>;
|
|
24
|
+
init?: NonAttribute<() => void>;
|
|
24
25
|
static get HiddenAttributes(): string[];
|
|
25
26
|
static get Columns(): Columns;
|
|
26
27
|
static get ColumnIndexes(): Index[];
|