@koalarx/nest 3.1.15 → 3.1.16

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.
@@ -58,17 +58,22 @@ class RepositoryBase {
58
58
  }
59
59
  getSelectRootPrismaSchema(entity) {
60
60
  const selectSchema = {};
61
- Object.keys(entity)
62
- .filter((key) => !['_id', '_action'].includes(key))
63
- .filter((key) => !(entity[key] instanceof Function || entity[key] instanceof list_1.List))
64
- .forEach((key) => {
65
- if (entity[key] instanceof entity_base_1.EntityBase) {
66
- selectSchema[key] = {
67
- select: this.getSelectRootPrismaSchema(entity[key]),
61
+ const entityProps = auto_mapping_list_1.AutoMappingList.getAllProps(entity);
62
+ entityProps.forEach((prop) => {
63
+ let instance;
64
+ try {
65
+ instance = new (prop.type())();
66
+ }
67
+ catch {
68
+ instance = null;
69
+ }
70
+ if (instance instanceof entity_base_1.EntityBase) {
71
+ selectSchema[prop.name] = {
72
+ select: this.getSelectRootPrismaSchema(instance.constructor),
68
73
  };
69
74
  }
70
75
  else {
71
- selectSchema[key] = true;
76
+ selectSchema[prop.name] = true;
72
77
  }
73
78
  });
74
79
  return selectSchema;
@@ -285,7 +290,7 @@ class RepositoryBase {
285
290
  async loadRelationForEntity(where, entity, cache) {
286
291
  return this._context[(0, KlString_1.toCamelCase)((0, KlString_1.toCamelCase)(entity.name))]
287
292
  .findFirst({
288
- select: this.getSelectWithRelationsId(entity),
293
+ select: this.getSelectRootPrismaSchema(entity),
289
294
  where,
290
295
  })
291
296
  .then((data) => this.enrichEntityWithRelations(entity, data, cache));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalarx/nest",
3
- "version": "3.1.15",
3
+ "version": "3.1.16",
4
4
  "description": "",
5
5
  "author": "Igor D. Rangel",
6
6
  "license": "MIT",