-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Polymorphic relation type #2487
Comments
cc @aharbis |
Thanks @dhmlau! Yes, this is a huge feature for our use-case. I'm happy to assist in design / testing / contributing where I can. |
Is this being actively pursued or is contribution welcome ? |
@hanut, it's not being actively pursued but contribution is always welcome.
@bajtos might be able to shed some light on this. cc @hacksparrow |
Absolutely! Let me assign it to you then. Thank you! |
Hi @hanut, thank you for picking up this task! Please let us know if you need any help, the fastest option is to reach out in Adding a new relation type usually involves a lot of design decisions to be made and many lines of code. It's best to open a draft pull request as early as you have something to show. This way we can discuss the right direction early on and avoid extensive rework (and wasted efforts) later on. Good luck! 🍀 I am looking forward to see you proposal. ✌️ |
I have been working on an implementation and am stuck with a few considerations -
For my use case, I implemented polymorphic relations using simple hasMany <-> belongsTo relations, one for each type of the morphable type. It works fine but at the expense of having nulls in the database. I would like to get your view on this as I am pretty stuck with how to move forward with it. |
For prosperity, I'm cross posting the reply from @bajtos on Slack:
|
Are there any news related to this topic? I really need to implement this relation ASAP |
Hi any progress on this topic? |
Addressing the feature parity of polymorphic relations from lb3, and the syntax is similar to lb3. The changes are backward compatible with previous apis. hasOne, belongsTo, and hasManyThrough relations are supported, while hasMany relation can only facilitate this feature with an additional one-on-one relation. Related to #2487 Signed-off-by: David Zhang <[email protected]>
This issue has now been solved by f4b8158 |
Support polymorphic relation type.
For example, as single
AccessToken
model class can belong to multiple user-like model classes, using AccessToken'sprincipalType
property to distinguish between the targets.See also LB 3.x docs: https://loopback.io/doc/en/lb3/Polymorphic-relations.html
The text was updated successfully, but these errors were encountered: