Questions about more complex scenarios #2164
Unanswered
frederikhors
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Any advancements? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I opened this question on SeaORM discussions, but I think this can be useful also to people here. Can you hint me a direction?
I have a project with these models and relations:
This is an example, of course, but as you can see I can have on table
Player
ateam_id
column as FK (Foreign Key) forTeam
which hascoach_id
column as FK forCoach
table.In my Golang backend I'm using an ORM that allows you to (generate and) use this kind of code:
Starting with Rust I was fascinated by SeaORM but now that I'm trying to create something more complex I have realized that I cannot do things like in Go.
I'm generating entities using
sea-orm-cli
from my Postgresql DB created using SeaORM Migrator (this is totally optional, you can also write the following code by yourself).The generated entities are like this:
And I'm using code like:
I'd like to know what you think of this mental order.
Most likely I need to change it because the code is really ugly (as well as expensive for the many SQL queries and allocations) and inconvenient to use to scale with even more complexity.
What do you recommend?
Beta Was this translation helpful? Give feedback.
All reactions