@koalarx/nest 3.1.41 → 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.
|
@@ -455,29 +455,35 @@ class RepositoryBase {
|
|
|
455
455
|
return Promise.all([]);
|
|
456
456
|
}
|
|
457
457
|
return Promise.all(relationCreate.relations.map((relation) => {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
relation[relationPropName] =
|
|
462
|
-
this.getConnectPrismaSchemaForRelation(relationCreate.entityInstance, response);
|
|
458
|
+
if (relation._action === entity_base_1.EntityActionType.update &&
|
|
459
|
+
relation._hasUpdate) {
|
|
460
|
+
return this.persistRelations(transaction, relation);
|
|
463
461
|
}
|
|
464
|
-
|
|
465
|
-
.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const idPropName = this.getIdPropName(relation);
|
|
471
|
-
if (!Array.isArray(idPropName)) {
|
|
472
|
-
relation[idPropName] = response[idPropName];
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
idPropName.forEach((propName) => {
|
|
476
|
-
relation[propName] = response[propName];
|
|
477
|
-
});
|
|
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);
|
|
478
468
|
}
|
|
479
|
-
return
|
|
480
|
-
|
|
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
|
+
}
|
|
481
487
|
}));
|
|
482
488
|
})),
|
|
483
489
|
]);
|