@koalarx/nest 3.1.18 → 3.1.20
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.
|
@@ -108,19 +108,26 @@ class RepositoryBase {
|
|
|
108
108
|
return selectSchema;
|
|
109
109
|
}
|
|
110
110
|
getPropNameFromEntitySource(source, entity) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
const entityProps = auto_mapping_list_1.AutoMappingList.getAllProps(source);
|
|
112
|
+
return entityProps.find((prop) => {
|
|
113
|
+
let instance;
|
|
114
|
+
try {
|
|
115
|
+
instance = new (prop.type())();
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
instance = null;
|
|
119
|
+
}
|
|
120
|
+
if (instance) {
|
|
121
|
+
if (instance.constructor.name === entity.name) {
|
|
115
122
|
return true;
|
|
116
123
|
}
|
|
117
|
-
else if (source[
|
|
118
|
-
const list = source[
|
|
124
|
+
else if (source[prop.name] instanceof list_1.List) {
|
|
125
|
+
const list = source[prop.name];
|
|
119
126
|
return list.entityType?.name === entity.name;
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
return false;
|
|
123
|
-
});
|
|
130
|
+
})?.name;
|
|
124
131
|
}
|
|
125
132
|
listRelationEntities(entity, fromList = false) {
|
|
126
133
|
const relationEntities = [];
|
|
@@ -150,7 +157,7 @@ class RepositoryBase {
|
|
|
150
157
|
const entityInstance = list.entityType;
|
|
151
158
|
const modelName = entityInstance.name;
|
|
152
159
|
const parentModelName = entity.constructor.name;
|
|
153
|
-
const parentPropName = this.getPropNameFromEntitySource(
|
|
160
|
+
const parentPropName = this.getPropNameFromEntitySource(entityInstance, entity.constructor) ?? (0, KlString_1.toCamelCase)(parentModelName);
|
|
154
161
|
if (modelName) {
|
|
155
162
|
list.toArray('removed').forEach((item) => {
|
|
156
163
|
relationDeletes.push({
|
package/package.json
CHANGED
|
@@ -56,10 +56,12 @@ class InMemoryBaseRepository {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
getNewId() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
:
|
|
59
|
+
if (this.typeId === 'number') {
|
|
60
|
+
const lastId = new KlArray_1.KlArray(this.items).orderBy('_id', 'desc')[0]
|
|
61
|
+
?._id;
|
|
62
|
+
return lastId ? lastId + 1 : 1;
|
|
63
|
+
}
|
|
64
|
+
return (0, node_crypto_1.randomUUID)();
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
exports.InMemoryBaseRepository = InMemoryBaseRepository;
|