-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Foreign Key Marker #388
Comments
Hey @lbcat06, welcome!! I see the potential use case of it in web API. I'm thinking if it's only for selecting data from the database (readonly)? Or, it's mutable and can use for saving data back into the database? |
I am not too well versed in SQL so I'm not quite sure whether writing operations using JOIN are feasible (I do think it is, so I think making it mutable would be great), but I am sure it would be feasible for readonly JOIN operations. Ideally it would be both, as this would allow to denormalise the data for more intuitive use within APIs and such. |
I think the type definition of |
Sounds like a good idea, I am not sure how passing that over a web api would work though. |
Hey! I am pretty interested in this feature being added to First of all regarding @lbcat06 concern on how a Regarding the feature, I have some ideas on how to implement this but I am not sure 100% on where to start and the implications of an addition like this to
Apart from this, I have multiple questions:
Cheers! 😄 |
Hey @PauMAVA, thanks for reaching out!! We love to see more and more contributors joining in! @RomainMazB are you working on this? #415 |
I am working on #415 yes (not the foreign_key). I have to admit that I may have to learn some few things about trait types and other stuff in the rust's typing-system to succeed but yes, I'm actively working on it. |
Hello @RomainMazB ! That's good as we will need the save methods in order to make the |
As explained in https://www.sea-ql.org/blog/2022-05-14-faq-01/ this API style is not the best fit for Rust |
Hello,
I am wondering of the possibility to mark foreign_keys in models the same way primary_keys are marked. This would allow the entry of the foreign_key to exist directly inside the model. I imagine the syntax to be something like:
#[sea_orm(foreign_key)]
, in the case of Fruit and Cake (as per the example provided in examples/basic) I would imagine it to be like this:Queries utilising
JOIN
should make this quite feasible, but if the idea of containing the model directly within another model destroys the model (I cannot think of a synonym x)) of this project, maybe this foreign_key marker could reduce boiler plate for defining relations.The text was updated successfully, but these errors were encountered: