pangea-server 3.3.96 → 3.3.97

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
- // TODO
310
- // No necesito esto ahora pero cuando lo active
311
- // porque agregue el "instance.init?.(lang)"
312
- // hay varios virtuals de relaciones que se van a romper.
313
- // Ejemplo: amountInClientCoin en Asset de Spendix
314
- // ----------------------
315
- // for (const [relName] of Object.entries(model.Relations)) {
316
- // const relInstance = (instance as any)[relName];
317
- // if (!relInstance) continue;
318
- // const relModel = model.Relations[relName].getModelFn();
319
- // if (Array.isArray(relInstance)) {
320
- // relInstance.forEach((instance) => processInstance(relModel, instance));
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[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.96",
4
+ "version": "3.3.97",
5
5
  "files": [
6
6
  "dist"
7
7
  ],