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

Define models relations in JSON file or in JavaScript code #695

Closed
yagobski opened this issue Nov 2, 2017 · 15 comments
Closed

Define models relations in JSON file or in JavaScript code #695

yagobski opened this issue Nov 2, 2017 · 15 comments
Labels
feature Relations Model relations (has many, etc.) stale

Comments

@yagobski
Copy link

yagobski commented Nov 2, 2017

e.g. LoopBack 3 has models relations definition in JSON file or in JavaScript code
We would like to define models relations in LoopBack 4 as well. Definition of relations need to auto generate the api services.

@dhmlau
Copy link
Member

dhmlau commented Mar 14, 2018

@yagobski , do you think this spike cover what you're looking for?
#995 . If yes, is it ok to close this issue and continue the discussion over there? thanks.

@dhmlau dhmlau added the DP3 label Apr 10, 2018
@jannyHou
Copy link
Contributor

jannyHou commented Jun 6, 2018

I feel it's too earlier for team to discuss the declarative relation file before story #1372 finished, we can revisit it later this month to groom it.

@dhmlau dhmlau added non-DP3 and removed DP3 labels Jun 12, 2018
@bajtos
Copy link
Member

bajtos commented Jun 25, 2018

I think this feature proposal would be covered by #1359

@elv1s
Copy link
Contributor

elv1s commented Oct 24, 2018

We'd like to move to LB4, but can't move until we are able to have relationships specified in a JSON model. Any idea on what milestone this issue will be a part of? Thanks!

@bajtos
Copy link
Member

bajtos commented Oct 25, 2018

@elv1s what kind of relations are you looking for? We already support hasMany and belongsTo as of 4.0 GA, the work on hasOne is in progress - see #1879. The Epic #1450 is keeping track of the remaining relations, could you please leave a comment there to mention the relations that are important to your project?

@bajtos
Copy link
Member

bajtos commented Oct 25, 2018

@elv1s maybe I misunderstood you. Are you saying that you would like everything relation-related to be provided by LB4 runtime based on few lines of JSON config? I mean the controller for REST API, repositories for accessing relation data, etc.?

@elv1s
Copy link
Contributor

elv1s commented Oct 25, 2018

@bajtos, yes your second comment is what I was interested in. Right now in LB3 we are driving the creation of the API with JSON models. Will we be able to use LB3 JSON models with relationships in LB4? The relationships hasMany, belongsTo and hasOne should cover our requirements.

@bajtos
Copy link
Member

bajtos commented Oct 26, 2018

Cross-posting #1194 (comment).

Can lb3 model relations be used in lb4 with https://github.com/strongloop/loopback-datasource-juggler?

Yes, I think that should work if you create the models using juggler's DataSource and/or ModelBuilder APIs and thus completely bypass @loopback/repository. You will loose the ability to describe models as the OpenAPI schema though, you will need to implement a helper to build OpenAPI schema for juggler models yourself. Possible leveraging loopback-swagger.

@bajtos
Copy link
Member

bajtos commented Oct 26, 2018

@elv1s

Right now in LB3 we are driving the creation of the API with JSON models. Will we be able to use LB3 JSON models with relationships in LB4?

Hmm. I think our design should be flexible enough to allow you to do that, but I don't think we are going to support this use case out of the box, at least not in the next few months.

I have left a comment elsewhere explaining how to automatically wire repositories and controllers for models, the approach may work for you too. See #1889 (comment)

I think this discussion is somewhat related to Declarative Support #565

@yagobski
Copy link
Author

yagobski commented Nov 7, 2018

LB4 is great but changing model declaration will be hard to migrate from LB3 to LB4 without rewriting the whole application. Do you have any migration plan to follow from LB3 to LB4.

@bajtos
Copy link
Member

bajtos commented Nov 8, 2018

@yagobski

LB4 is great but changing model declaration will be hard to migrate from LB3 to LB4 without rewriting the whole application. Do you have any migration plan to follow from LB3 to LB4.

We are fully aware of this concern. We are discussing migration paths from LB 3.x in the issue #1849 - feel free to join the discussion and/or upvote the issue.

@dhmlau dhmlau added the Relations Model relations (has many, etc.) label Nov 28, 2018
@shashijangir

This comment has been minimized.

@bajtos

This comment has been minimized.

@stale
Copy link

stale bot commented Jun 20, 2020

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 CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@stale stale bot added the stale label Jun 20, 2020
@stale
Copy link

stale bot commented Jul 20, 2020

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Jul 20, 2020
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.) stale
Projects
None yet
Development

No branches or pull requests

6 participants