Skip to content

Commit 57b6457

Browse files
committed
test: debug test
1 parent 5d59365 commit 57b6457

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

libs/json-api/json-api-nestjs/src/lib/modules/micro-orm/orm-methods/post-relationship/post-relationship.ts

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,36 @@ export async function postRelationship<
1414
rel: Rel,
1515
input: PostRelationshipData
1616
): Promise<E> {
17-
try {
18-
const idsResult = await this.microOrmUtilService.validateRelationInputData(
19-
rel,
20-
input
21-
);
17+
const idsResult = await this.microOrmUtilService.validateRelationInputData(
18+
rel,
19+
input
20+
);
2221

23-
const currentEntityRef =
24-
this.microOrmUtilService.entityManager.getReference(
25-
this.microOrmUtilService.entity,
26-
id as any
27-
);
22+
const currentEntityRef = this.microOrmUtilService.entityManager.getReference(
23+
this.microOrmUtilService.entity,
24+
id as any
25+
);
2826

29-
const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();
27+
const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();
3028

31-
if (Array.isArray(idsResult)) {
32-
const relRef = idsResult.map((i) =>
33-
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
34-
);
35-
currentEntityRef[rel].add(...relRef);
36-
} else {
37-
// @ts-ignore
38-
currentEntityRef[rel] =
39-
this.microOrmUtilService.entityManager.getReference(
40-
relEntity,
41-
idsResult as any
42-
);
43-
}
29+
if (Array.isArray(idsResult)) {
30+
const relRef = idsResult.map((i) =>
31+
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
32+
);
33+
currentEntityRef[rel].add(...relRef);
34+
} else {
35+
// @ts-ignore
36+
currentEntityRef[rel] = this.microOrmUtilService.entityManager.getReference(
37+
relEntity,
38+
idsResult as any
39+
);
40+
}
4441

45-
await this.microOrmUtilService.entityManager.flush();
42+
await this.microOrmUtilService.entityManager.flush();
4643

47-
return getRelationship.call<
48-
MicroOrmService<E>,
49-
Parameters<typeof getRelationship<E, Rel>>,
50-
ReturnType<typeof getRelationship<E, Rel>>
51-
>(this, id, rel);
52-
} catch (e) {
53-
console.log(e);
54-
throw e;
55-
}
44+
return getRelationship.call<
45+
MicroOrmService<E>,
46+
Parameters<typeof getRelationship<E, Rel>>,
47+
ReturnType<typeof getRelationship<E, Rel>>
48+
>(this, id, rel);
5649
}

libs/json-api/json-api-nestjs/src/lib/modules/micro-orm/service/micro-orm-util.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ export class MicroOrmUtilService<E extends ObjectLiteral> {
720720
},
721721
})
722722
.getResult();
723-
console.log(checkResult, prepareData, rel, inputData);
723+
724724
if (checkResult.length === prepareData.length) {
725725
return (
726726
isArray ? inputData.map((i) => i.id) : inputData.id

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy