@koalarx/nest 3.1.15 → 3.1.17
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
else {
|
|
71
|
-
selectSchema[
|
|
75
|
+
else if (!(instance instanceof list_1.List)) {
|
|
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.
|
|
293
|
+
select: this.getSelectRootPrismaSchema(entity),
|
|
289
294
|
where,
|
|
290
295
|
})
|
|
291
296
|
.then((data) => this.enrichEntityWithRelations(entity, data, cache));
|
|
@@ -304,7 +309,7 @@ class RepositoryBase {
|
|
|
304
309
|
const entityInstance = list.entityType;
|
|
305
310
|
relationKeys.push(propName);
|
|
306
311
|
const items = [];
|
|
307
|
-
data[propName]
|
|
312
|
+
data[propName]?.forEach((item) => {
|
|
308
313
|
const cacheKey = `${entity.constructor.name}-${propName}-${this.getIdOnEntity(new entityInstance(), item)}`;
|
|
309
314
|
if (cache.has(cacheKey)) {
|
|
310
315
|
items.push(Promise.resolve(cache.get(cacheKey)));
|