-
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
Spike: Declarative definition of FOREIGN KEY and UNIQUE constraints #2606
Comments
Timebox 2.5 weeks please. |
spike pull request: #2712 |
Created the following follow-up stories:
Closing this spike as done. |
This comment has been minimized.
This comment has been minimized.
@odykyi Thanks for the ethusiasm to help others! ❤️ However please refrain from re-posting the same solution on other issues unless it directly resolves the issue at hand. This may pollute the contributors' (email) notifications which may make it difficult to sort through other issues. For example, this is a spike for a new feature that has already been closed. Hence a workaround isn't needed. For others closed/stale issues, it's better to open a new issue if you're experiencing a similar issue as the codebase may have changes significantly since the original issue was opened. Nonetheless, I hope this doesn't discourage from future contributions to open source projects, including LoopBack 😃 |
To support strong relations with referential integrity enforced by the database, we need a mechanism allowing models to define FOREIGN KEY and UNIQUE constraints in a declarative way.
Let's consider the relation "Customer has one Account", using
account.customerId
as the relational property. As part of the domain model definition, we need to define the following constraints:account.customerId
must be an existing customer id.Things to consider:
UNIQUE constraint can be composite. E.g. on GitHub, we want the combination of
(user, repo)
to be unique.FOREIGN KEY constraints can be composite too. See e.g. here:
In LB3 (and loopback-datasource-juggler), we may already have partial support for foreign keys.
Acceptance criteria
@foreignKey()
and@unique()
?There should be a pull request with any spike/PoC bits of code used to verify the proposals, and a
/_SPIKE_.md
file with the spike documentation (description or the current status, high-level overview of the proposals, etc.)Out of scope
The text was updated successfully, but these errors were encountered: