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

Implement InclusionResolver for hasManyThrough relation #5946

Closed
5 tasks
agnes512 opened this issue Jul 16, 2020 · 10 comments · Fixed by #6280
Closed
5 tasks

Implement InclusionResolver for hasManyThrough relation #5946

agnes512 opened this issue Jul 16, 2020 · 10 comments · Fixed by #6280
Assignees
Labels
feature Relations Model relations (has many, etc.)

Comments

@agnes512
Copy link
Contributor

Acceptance criteria

  • Implement a factory function for creating an inclusion resolver for the given hasManyThrough relation (similar to feat(repository): implement inclusionResolver for hasMany relation #3595).
  • Enhance HasManyThroughRepositoryFactory to provide resolver property.
  • Write tests in packages/repository-tests to verify that resolver works for real databases.
  • Feel free to write unit-level tests using mocked repositories too, as needed.
  • Update documentation (e.g.hasManyThrough relation page and relation cli page) to explain how to enable or disable inclusion. Include examples showing how to build a query to include related model(s).
@agnes512 agnes512 added feature Relations Model relations (has many, etc.) labels Jul 16, 2020
@cardea-fletcher
Copy link

cardea-fletcher commented Aug 20, 2020

(8-20-2020) Just to be clear, I have 2 tables (doctors, patients) and a many-many relationship between them using a hasManyThrough relationship, generated with the relation generator , does this mean that there is no way to get the relations between those 2 things via the controller? For instance, return doctors, and all their patients?

Thanks in advance!

Also sorry if this doesn't go here, just trying to understand what has been built yet!

@agnes512
Copy link
Contributor Author

@cardea-fletcher Yes. Currently only the relation is implemented, which means you can get the related models based on the foreign key. But getting parent models together with their related models is not supported yet as this is done by the inclusionResolver. As a workaround you need to send 2 queries.

@ErwSim
Copy link

ErwSim commented Sep 23, 2020

When will this be published to npm ?

@nabdelgadir
Copy link
Contributor

@ErwSim hi, check for it early next week.

@dutchiexl
Copy link

Could you elaborate on how the workaround with 2 queries work ?

I need 3 queries and then have to traverse over every object to link them together. Is there a better way ?

@ErwSim
Copy link

ErwSim commented Oct 1, 2020

@nabdelgadir Still not available ? 😥

@nabdelgadir
Copy link
Contributor

@ErwSim hi, sorry for the delay, but check again next week 🤞 I'll post a comment here when it's available.

@SebastianDaehnrich
Copy link

@nabdelgadir : do you have an idea when this will be available? :)

@nabdelgadir
Copy link
Contributor

@ErwSim @SebastianDaehnrich there was just a new release, so it should be available now 😄

@ErwSim
Copy link

ErwSim commented Oct 7, 2020

Yay, thanks @nabdelgadir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Relations Model relations (has many, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants