-
Notifications
You must be signed in to change notification settings - Fork 13
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
Questions about more complex scenarios using SeaORM and clean architecture #15
Comments
Thank you! I do indeed love ideas for new content, so I appreciate you taking the time to put together so much detail! I've definitely struggled a bit with this aspect of SeaORM, and even went so far as to fork it to support more JOINs. I came up with some good strategies, but sometimes you'll just have to fall back to something more like raw SQL, unfortunately. I'll take some time to review this over the weekend and come up with a good approach. |
I haven't found an approach I really like yet. In my own projects, I've typically been using Dataloaders to work around this. I'll optimize one relationship with I did, however, find another page in their cookbook that mentions using the SeaQuery builder and converting it into your entity type using FromQueryResult, which SeaORM can derive for you. I've used this method for custom joins in other projects, but next time I think I'll use SeaQuery instead. I like the API better. I'll try to find the time soon to add an example here - maybe using a custom join to list Shows, join in Episodes, and also join in Users who have a RoleGrant for the "guest" role for each Episode related to each Show. If I can find a way to use |
You've described pretty much everything I've found and tried too. I'm thinking of trying directly with https://github.com/launchbadge/sqlx. The example you mention would be very handy also because there are only "hello world" examples around. |
I also opened dpc/sniper#3. I suggest you to read because there is another idea to use a "Store" which is an |
Did you find a better way? |
♥ |
Sadly, I've been at full capacity and haven't been able to come back to this. I'm working on a big Go project, and also trying to build up a Rust side-project at the same time, while also trying to extract a framework that I can use to build more side projects faster. 😅 I'm planning on coming back to this as I implement an example project in my new framework, but I just haven't had the time to do so yet. Sorry for the slow response here! |
@bkonkle I saw that you answered "on video" to the other two issues and soon I will be able to watch and learn from the wonder you are creating.
Since you are a content creator perhaps the following question could offer you more food for thought and therefore videos! : smile:
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?
The text was updated successfully, but these errors were encountered: