@koalarx/nest 3.1.40 → 3.1.42
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.
|
@@ -264,6 +264,15 @@ class RepositoryBase {
|
|
|
264
264
|
prismaSchema[key] = this.getConnectPrismaSchemaForRelation(entity[key]);
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
+
else if (entity[key] === null) {
|
|
268
|
+
const propDefinitions = auto_mapping_list_1.AutoMappingList.getPropDefinitions(entity.constructor, key);
|
|
269
|
+
const relationEntity = auto_mapping_list_1.AutoMappingList.getSourceByName(propDefinitions?.type ?? '');
|
|
270
|
+
if (relationEntity) {
|
|
271
|
+
prismaSchema[key] = {
|
|
272
|
+
disconnect: true,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
267
276
|
else if (!(entity[key] instanceof list_1.List)) {
|
|
268
277
|
prismaSchema[key] = entity[key];
|
|
269
278
|
}
|
|
@@ -446,29 +455,35 @@ class RepositoryBase {
|
|
|
446
455
|
return Promise.all([]);
|
|
447
456
|
}
|
|
448
457
|
return Promise.all(relationCreate.relations.map((relation) => {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
relation[relationPropName] =
|
|
453
|
-
this.getConnectPrismaSchemaForRelation(relationCreate.entityInstance, response);
|
|
458
|
+
if (relation._action === entity_base_1.EntityActionType.update &&
|
|
459
|
+
relation._hasUpdate) {
|
|
460
|
+
return this.persistRelations(transaction, relation);
|
|
454
461
|
}
|
|
455
|
-
|
|
456
|
-
.
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const idPropName = this.getIdPropName(relation);
|
|
462
|
-
if (!Array.isArray(idPropName)) {
|
|
463
|
-
relation[idPropName] = response[idPropName];
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
idPropName.forEach((propName) => {
|
|
467
|
-
relation[propName] = response[propName];
|
|
468
|
-
});
|
|
462
|
+
else if (relation._action === entity_base_1.EntityActionType.create) {
|
|
463
|
+
const relationPropName = this.getPropNameFromEntitySource(relation.constructor, relationCreate.entityInstance);
|
|
464
|
+
if (relationPropName &&
|
|
465
|
+
!(relation[relationPropName] instanceof list_1.List)) {
|
|
466
|
+
relation[relationPropName] =
|
|
467
|
+
this.getConnectPrismaSchemaForRelation(relationCreate.entityInstance, response);
|
|
469
468
|
}
|
|
470
|
-
return
|
|
471
|
-
|
|
469
|
+
return transaction[(0, KlString_1.toCamelCase)(relation.constructor.name)]
|
|
470
|
+
.create({
|
|
471
|
+
data: this.entityToPrisma(relation),
|
|
472
|
+
select: this.getSelectRootPrismaSchema(relation.constructor),
|
|
473
|
+
})
|
|
474
|
+
.then((response) => {
|
|
475
|
+
const idPropName = this.getIdPropName(relation);
|
|
476
|
+
if (!Array.isArray(idPropName)) {
|
|
477
|
+
relation[idPropName] = response[idPropName];
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
idPropName.forEach((propName) => {
|
|
481
|
+
relation[propName] = response[propName];
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return this.persistRelations(transaction, relation);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
472
487
|
}));
|
|
473
488
|
})),
|
|
474
489
|
]);
|