@koalarx/nest 3.1.38 → 3.1.39
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.
|
@@ -403,7 +403,35 @@ class RepositoryBase {
|
|
|
403
403
|
return Promise.all([]);
|
|
404
404
|
}
|
|
405
405
|
return Promise.all(relationUpdate.relations.map((relation) => {
|
|
406
|
-
|
|
406
|
+
if (relation._action === entity_base_1.EntityActionType.update &&
|
|
407
|
+
relation._hasUpdate) {
|
|
408
|
+
return this.persistRelations(transaction, relation);
|
|
409
|
+
}
|
|
410
|
+
else if (relation._action === entity_base_1.EntityActionType.create) {
|
|
411
|
+
const relationPropName = this.getPropNameFromEntitySource(relation.constructor, relationUpdate.entityInstance);
|
|
412
|
+
if (relationPropName &&
|
|
413
|
+
!(relation[relationPropName] instanceof list_1.List)) {
|
|
414
|
+
relation[relationPropName] =
|
|
415
|
+
this.getConnectPrismaSchemaForRelation(relationUpdate.entityInstance, entity);
|
|
416
|
+
}
|
|
417
|
+
return transaction[(0, KlString_1.toCamelCase)(relation.constructor.name)]
|
|
418
|
+
.create({
|
|
419
|
+
data: this.entityToPrisma(relation),
|
|
420
|
+
select: this.getSelectRootPrismaSchema(relation.constructor),
|
|
421
|
+
})
|
|
422
|
+
.then((response) => {
|
|
423
|
+
const idPropName = this.getIdPropName(relation);
|
|
424
|
+
if (!Array.isArray(idPropName)) {
|
|
425
|
+
relation[idPropName] = response[idPropName];
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
idPropName.forEach((propName) => {
|
|
429
|
+
relation[propName] = response[propName];
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return this.persistRelations(transaction, relation);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
407
435
|
}));
|
|
408
436
|
})),
|
|
409
437
|
]);
|
|
@@ -423,7 +451,23 @@ class RepositoryBase {
|
|
|
423
451
|
relation[relationPropName] =
|
|
424
452
|
this.getConnectPrismaSchemaForRelation(relationCreate.entityInstance, response);
|
|
425
453
|
}
|
|
426
|
-
return
|
|
454
|
+
return transaction[(0, KlString_1.toCamelCase)(relation.constructor.name)]
|
|
455
|
+
.create({
|
|
456
|
+
data: this.entityToPrisma(relation),
|
|
457
|
+
select: this.getSelectRootPrismaSchema(relation.constructor),
|
|
458
|
+
})
|
|
459
|
+
.then((response) => {
|
|
460
|
+
const idPropName = this.getIdPropName(relation);
|
|
461
|
+
if (!Array.isArray(idPropName)) {
|
|
462
|
+
relation[idPropName] = response[idPropName];
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
idPropName.forEach((propName) => {
|
|
466
|
+
relation[propName] = response[propName];
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return this.persistRelations(transaction, relation);
|
|
470
|
+
});
|
|
427
471
|
}));
|
|
428
472
|
})),
|
|
429
473
|
]);
|