-
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
[Model Relation] hasAndBelongsToMany #2308
Comments
I briefly reviewed the document. It seems to be a great start. Thanks @RaphaelDrai |
@RaphaelDrai I'm assuming you want this code in the |
I've started work on this. You can see my progress at #2315. |
@codejamninja Hello, yes it is a mistake in my document. The file name in bullet 8 is indeed "has-and-belongs-to-many.decorator.ts" and not "has-and-belongs-to-many.repository.ts" |
One challenge I ran into that I would like some feedback on is where and when to create the junction table schemas. The other relations only use schemas a user defines in models. In this particular relation, we will need schemas created outside of the user defined models. |
I just realized I don't have to worry about creating the junction table with the hasManyThrough relation because the junction table is defined by the user in a model. I'm going to start implementing hasManyThrough before I finish this implementation. Thanks for the suggestion @bajtos. |
Hey, I would like to discuss the definition of the default API that will be provided by this relation. Assuming STUDENTS hasAndBelongsToMany CLASS, my opinion is to provide the following API: GET ALL THE CLASSES OF A SPECIFIC STUDENT:
CREATE A CLASS AND CONNECT IT TO THE STUDENT
FINDS A CLASS AND CONNECT IT TO THE STUDENT
REMOVES A CLASS FROM THE STUDENT
REMOVES ALL CLASSES FROM THE STUDENT
UPDATE A CLASS OF THE STUDENT
UPDATE ALL CLASSES OF THE STUDENT
GET ALL STUDENTS BY CLASS
Would be happy to hear your opinions about it. |
@TomerSalton thank you for writing down your proposal, I think it's a good start. Please note that we need to consider the Repository API provided to TS/JS consumers too, not only the REST API. I have two comments regarding the proposed REST endpoints:
I am concerned about these URLs, I think they may be confusing for API consumers - are we deleting the relation (link) only, or deleting also the target model? In LoopBack 3.x, we have two flavours:
I think it would be good to preserve both endpoints in LB4 too.
IMO, this endpoint does not belong to Student REST API, it should be implemented on Class REST API as What do you think? /cc @strongloop/loopback-next |
Sounds perfect.
The reason I put this relation last is because I wasn't sure about it - from the same reason. |
@TomerSalton @bajtos I am very glad to see you start to contribute many-to-many relation! My personal idea about the API is that we may support to create the relation just from one side as @TomerSalton proposed, and also support to retrieve the relation from both sides. For instance, GET ALL STUDENTS BY CLASS GET ALL CLASSES BY STUDENT The API, GET http://root/students/classes/{class_id}, in previous comment looks a little strange. And I am not quite sure if HTTP router may regard 'classes' as a student id, according to some other API path registration. |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
Description / Steps to reproduce / Feature proposal
Originated from #2043
This issue is created specific for
hasAndBelongsToMany
because the original issue contains other types of model relation.A few comments from #2043 that are related to
hasAndBelongsToMany
.hasAndBelongsToMany
: Many to many relation (hasAndBelongsToMany) #2043 (comment).md
or in gist for easier review (?)cc @RaphaelDrai @TomerSalton @codejamninja - Since you've expressed interests to implement this model relation type, I'm assigning it to you. Please let me know if i'm wrong and i can remove you from the assignees list. Also, if there's anything I can help facilitating, please let me know.
The text was updated successfully, but these errors were encountered: