Skip to content
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

Add relationships to the Requirement class directly #463

Closed
mlhaufe opened this issue Nov 20, 2024 · 0 comments · Fixed by #468
Closed

Add relationships to the Requirement class directly #463

mlhaufe opened this issue Nov 20, 2024 · 0 comments · Fixed by #468
Assignees
Milestone

Comments

@mlhaufe
Copy link
Contributor

mlhaufe commented Nov 20, 2024

In Object Orientation, relationships are generally managed as references from itself and not stored as standalone entities.

a -[contradicts]-> b

instead of

a -[contradicts]- b

Currently, to access an entity and its associated relations extra calls must be made to the server and database and/or extra parameters must be provided to obtain the desired entities

Example problem:

To obtain a list of SystemComponent an organizationSlug and solutionSlug must be provided.
The parent components are not included in this call though because the belongs relationship between parent and child are available until a subsequent call is made:

#453

This use case can not be resolved generically as things stand now:

image

Creating more endpoints to support each potential relationship that might exist is non-trivial and a potential maintenance nightmare.

To resolve the issue, the relations should be defined on the Requirement entity as @ManyToMany.

ORM reference: https://mikro-orm.io/docs/relationships#manytomany

A challenge though here is that the default behavior of the ORM is to generate multiple junction tables (one per relation). Currently the database has a single table for relations:

image

This could be mitigated by providing the explicit pivot entity:

@ManyToMany({ entity: () => Foo, pivotEntity: () => Bar })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant