Skip to content

Try to adopt for MicroOrm #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7856814
refactor(json-api-nestjs): Remove old files
klerick Jan 22, 2025
f22bf49
refactor(json-api-nestjs): Deep refactoring
klerick Jan 22, 2025
3e828a5
refactor(json-api-nestjs-sdk): Rename npm package and fox data
klerick Jan 22, 2025
ccb835d
refactor(json-api-nestjs): Rename npm package and fox data
klerick Jan 22, 2025
77c7d03
chore: Change README.md
klerick Jan 22, 2025
84f69ab
refactor(json-api-nestjs): Remove old files
klerick Jan 22, 2025
792bf2c
refactor(json-api-nestjs): Deep refactoring
klerick Jan 22, 2025
750f685
refactor(json-api-nestjs-sdk): Rename npm package and fox data
klerick Jan 22, 2025
8935ade
refactor(json-api-nestjs): Rename npm package and fox data
klerick Jan 22, 2025
ab025bf
chore: Change README.md
klerick Jan 22, 2025
0bbe933
Merge remote-tracking branch 'origin/nestjs-json-api-97' into nestjs-…
klerick Jan 22, 2025
f41fe6a
test(json-api-nestjs-sdk): Fix tests
klerick Jan 22, 2025
30b3988
refactor(json-api-nestjs): some refactoring swagger generator
klerick Jan 22, 2025
1ae2585
refactor(json-api-nestjs): add method for validate from microorm
klerick Jan 25, 2025
8cd7955
refactor(json-api-nestjs): add method for validate from microorm
klerick Jan 25, 2025
18f4a0c
feat(json-api-nestjs): Microro orm
klerick Feb 10, 2025
4696f51
feat(json-api-nestjs): Microro orm
klerick Feb 10, 2025
0a66259
test(json-api-nestjs): Fixe e2e test
klerick Feb 11, 2025
19df570
ci: exlude database from ci
klerick Feb 11, 2025
5d59365
test: debug test
klerick Feb 11, 2025
57b6457
test: debug test
klerick Feb 11, 2025
69acaa8
refactor(json-api-nestjs): move to project
klerick Feb 11, 2025
cbd1e71
refactor(json-api-nestjs-sdk): move to project
klerick Feb 11, 2025
bb8a415
refactor(json-api-nestjs): change npm package should be in next version
klerick Feb 11, 2025
0b7b4cc
refactor(json-api-nestjs): create modules for each orm
klerick Feb 12, 2025
e492cd1
fix(json-api-nestjs): Fix circular type for query obkect
klerick Feb 12, 2025
c2e9d1d
docs(json-api-nestjs): Add describe
klerick Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: debug test
  • Loading branch information
klerick committed Feb 11, 2025
commit 57b64574b7dfa1ec73d3d79312ac18d7f7634b51
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,36 @@ export async function postRelationship<
rel: Rel,
input: PostRelationshipData
): Promise<E> {
try {
const idsResult = await this.microOrmUtilService.validateRelationInputData(
rel,
input
);
const idsResult = await this.microOrmUtilService.validateRelationInputData(
rel,
input
);

const currentEntityRef =
this.microOrmUtilService.entityManager.getReference(
this.microOrmUtilService.entity,
id as any
);
const currentEntityRef = this.microOrmUtilService.entityManager.getReference(
this.microOrmUtilService.entity,
id as any
);

const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();
const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();

if (Array.isArray(idsResult)) {
const relRef = idsResult.map((i) =>
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
);
currentEntityRef[rel].add(...relRef);
} else {
// @ts-ignore
currentEntityRef[rel] =
this.microOrmUtilService.entityManager.getReference(
relEntity,
idsResult as any
);
}
if (Array.isArray(idsResult)) {
const relRef = idsResult.map((i) =>
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
);
currentEntityRef[rel].add(...relRef);
} else {
// @ts-ignore
currentEntityRef[rel] = this.microOrmUtilService.entityManager.getReference(
relEntity,
idsResult as any
);
}

await this.microOrmUtilService.entityManager.flush();
await this.microOrmUtilService.entityManager.flush();

return getRelationship.call<
MicroOrmService<E>,
Parameters<typeof getRelationship<E, Rel>>,
ReturnType<typeof getRelationship<E, Rel>>
>(this, id, rel);
} catch (e) {
console.log(e);
throw e;
}
return getRelationship.call<
MicroOrmService<E>,
Parameters<typeof getRelationship<E, Rel>>,
ReturnType<typeof getRelationship<E, Rel>>
>(this, id, rel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ export class MicroOrmUtilService<E extends ObjectLiteral> {
},
})
.getResult();
console.log(checkResult, prepareData, rel, inputData);

if (checkResult.length === prepareData.length) {
return (
isArray ? inputData.map((i) => i.id) : inputData.id
Expand Down
Loading