@koalarx/nest 3.1.38 → 3.1.40
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,36 @@ 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, relation[relationPropName] ??
|
|
416
|
+
relationUpdate.schema.where);
|
|
417
|
+
}
|
|
418
|
+
return transaction[(0, KlString_1.toCamelCase)(relation.constructor.name)]
|
|
419
|
+
.create({
|
|
420
|
+
data: this.entityToPrisma(relation),
|
|
421
|
+
select: this.getSelectRootPrismaSchema(relation.constructor),
|
|
422
|
+
})
|
|
423
|
+
.then((response) => {
|
|
424
|
+
const idPropName = this.getIdPropName(relation);
|
|
425
|
+
if (!Array.isArray(idPropName)) {
|
|
426
|
+
relation[idPropName] = response[idPropName];
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
idPropName.forEach((propName) => {
|
|
430
|
+
relation[propName] = response[propName];
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return this.persistRelations(transaction, relation);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
407
436
|
}));
|
|
408
437
|
})),
|
|
409
438
|
]);
|
|
@@ -423,7 +452,23 @@ class RepositoryBase {
|
|
|
423
452
|
relation[relationPropName] =
|
|
424
453
|
this.getConnectPrismaSchemaForRelation(relationCreate.entityInstance, response);
|
|
425
454
|
}
|
|
426
|
-
return
|
|
455
|
+
return transaction[(0, KlString_1.toCamelCase)(relation.constructor.name)]
|
|
456
|
+
.create({
|
|
457
|
+
data: this.entityToPrisma(relation),
|
|
458
|
+
select: this.getSelectRootPrismaSchema(relation.constructor),
|
|
459
|
+
})
|
|
460
|
+
.then((response) => {
|
|
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
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return this.persistRelations(transaction, relation);
|
|
471
|
+
});
|
|
427
472
|
}));
|
|
428
473
|
})),
|
|
429
474
|
]);
|