Replies: 2 comments 7 replies
-
|
I checked. Certainly a good idea! But I do not agree on the bit where we have to squash everything into one file, is there a benefit of doing so? |
Beta Was this translation helpful? Give feedback.
7 replies
-
|
PR created: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
From my experience, creating models with SeaORM seems like you have to map each column to your model 1:1 exactly, and making a mistake is something that would not be picked up at compile time.
I had previously mentioned an idea about the
DeriveModelmacro validating the struct at compile time, but after using the tonic library, it seems like there may be a better approach.My suggestion:
Create a library
sea-orm-build, which is to be used in abuild.rsfile as a build script, and generates models and relationships from a database connection.For example:
This would move all the models and relationships into a generated
models.rsfile which can be referenced by the app.Benefits:
Cons:
See tonic for an example of using the build.rs file to generate code: https://github.com/hyperium/tonic/tree/master/tonic-build
Beta Was this translation helpful? Give feedback.
All reactions