-
-
Notifications
You must be signed in to change notification settings - Fork 284
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
feat(objection): add model relationship decorators #2078
feat(objection): add model relationship decorators #2078
Conversation
Some extra thought I had on this PR:
|
d334351
to
e97a55a
Compare
Last thought I had on this, was that:
|
e97a55a
to
c72d935
Compare
Hello @rossyman, It seems to be ok for me :) Good PR. The documentation over the new decorators is missing. Don't forget to add it in /docs/tutorials/objection.md ;) See you |
c72d935
to
e650b24
Compare
Updated the documentation and fixed the build/test phase -- One point, is that I'm not sure what I need to do for |
@rossyman you can take as example the mongoose.md where the ApiList is used to display mongoose decorators ;) |
Ah okay so it seems the API is queried from |
It's possible to regenerate locally the api.json file by running the command: I'll checkout your PR to verify if the ApiList is correctly configured for Objection page. See you |
Tests are running into an issue with array types. Sadly this issue (microsoft/TypeScript#7169) has been open for 6 years now, so I'll add in some extra parameters to the configuration for relationships that are plural to expose this type. |
@rossyman Great job ;) Just small cosmetics changes ! See you |
f8b7661
to
926a7e7
Compare
|
@rossyman Perfect PR ;) Ready to merge for me! |
🎉 This PR is included in version 6.131.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 7.0.0-rc.6 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Information
First time contributor here 😄 If there are any striking concerns about this PR then please let me know, as I'm happy to work on it. I thought that it'd be useful for developers to use decorators to describe relationships via Objection.
This PR hopefully honours the way that Objection's Graph and Relationship Querying APIs work -- whilst also ensuring the consumer's domain model is a bit more strict, by actually defining related properties on an entity as optional, instead of only loosely defining them via
relationMappings
.The sensible defaults these decorators provide for joining keys are based on the use of
@IdColumn
and@Entity
. The defaults supplied are based on the Objection relationship documentation and follow the same nomenclature with the ability for a user to override the keys / table path in the decorator factory params.Usage example
Todos