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

feat(repository): created hasManyThrough following convention pattern #2356

Closed

Conversation

clayrisser
Copy link
Contributor

@clayrisser clayrisser commented Feb 8, 2019

I created some boilerplate for the hasThroughMany relation using the hasMany relation. Currently, this contains the identical functionality as the hasMany relation.

See also #2264

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codejamninja Thank you very much for implementing the relation with through model. We appreciate your effort!
IIUC, you retrieve the related entities in a similar way in LoopBack3:

Given user scenario Physician hasMany Patient through Appointment, you retrieve physician.patients by

  • Fetch the through entities using physician.id
  • Gather an array of ids of Appointment
  • Fetch the related patients using that array

This could actually be optimized by leveraging SQL join(if use SQL databases at backend). And LoopBack 3 users do give us feedback about the performance improvement. This is also a reason why we decided to defer the implementation of through relation.

I would like to get @raymondfeng involved in the discussion.
cc @strongloop/loopback-next any thought?

@clayrisser
Copy link
Contributor Author

Fyi, this code has not been tested. I'm still in the process of developing it.

I think I'm going to reimplement this using the hasMany relation with a through property.

That's how it was done in loopback 3.

https://loopback.io/doc/en/lb3/HasManyThrough-relations.html

@clayrisser clayrisser mentioned this pull request Feb 9, 2019
7 tasks
@clayrisser
Copy link
Contributor Author

I am closing this issue in favor of #2359

@clayrisser clayrisser closed this Feb 9, 2019
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 this pull request may close these issues.

3 participants