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

Model relations #812

Closed
arash01 opened this issue Dec 20, 2017 · 7 comments
Closed

Model relations #812

arash01 opened this issue Dec 20, 2017 · 7 comments

Comments

@arash01
Copy link
Contributor

arash01 commented Dec 20, 2017

I was wondering if model relations are implemented in current version or not yet?
I see some decorators such as @ belongsTo in source code but couldn't find any documentation about using them.

@shimks
Copy link
Contributor

shimks commented Dec 20, 2017

Currently there is no implementation for model relations. To stay up-to-date on its release, please follow #537.

@shimks shimks closed this as completed Dec 20, 2017
@arash01
Copy link
Contributor Author

arash01 commented Dec 23, 2017

I wish we had this feature on current release because without model relations, it's almost impossible for me to continue developing and testing on Loopback-Next :(

@arash01
Copy link
Contributor Author

arash01 commented Dec 23, 2017

Also as a friendly suggestion, please don't close an issue as soon as you post a reply. Keeping an issue open for short period of time gives opportunity to other users to be involved in discussion.

@bajtos
Copy link
Member

bajtos commented Jan 2, 2018

I'd like to reopen this issue.

In #537, we reached the conclusion that we are going to keep Juggler around, but we would like to eventually simplify both the features provides and the codebase. In that light I think it makes sense to discuss how to expose relations in LoopBack 4.

Here is my understanding of the current status:

  • Decorators like @belongsTo are just dummy placeholders not doing anything.
  • We don't have any helpers for exposing relation methods via REST API (or gRPC, etc.)

IMO, in order to make relations happen, two changes are needed:

  1. Build Repository classes for accessing related models, passing metadata from @belongsTo (and friends) to legacy juggler. For example, our DefaultCrudRepository creates a new backing PersistedModel from the definition provided by an Entity(a Model) annotated with decorators like @property. (source code).

  2. Come up with a convention for building Controller classes exposing relation methods via REST API. See [WIP] [RFC] feat: Add REST mapping for repository interfaces #740 for an inspiration. Eventually, there should be a CLI tool for generating these controllers whenever an app developer is adding a new relation.

@arash01 I am afraid support for relations is pretty down in our priority list. Would you like to contribute this feature yourself? We are happy to help you along the way.

@bajtos bajtos changed the title Creating model relations Model relations Jan 2, 2018
@arash01
Copy link
Contributor Author

arash01 commented Jan 3, 2018

Thanks for reply. I'm not sure if my TypeScript knowledge is enough to contribute in this project.

@dhmlau
Copy link
Member

dhmlau commented Feb 26, 2018

@arash01 , we've opened a github issue on the spike: #995.

@dhmlau
Copy link
Member

dhmlau commented Apr 10, 2018

Duplicate of #995

@dhmlau dhmlau marked this as a duplicate of #995 Apr 10, 2018
@dhmlau dhmlau closed this as completed Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants