hood
hood copied to clipboard
Loading Relations
I'm just curious if you were planning to handle loading of relations at any point?
e.g. If a User has an associated Account, would you say it should be represented as:
type User struct {
AccountId hood.Id
}
and it's up to the user to select it separately when they want?
Yes, I'd like to definitely implement that at some point, just don't know when (other stuff on my hands right now). If you want to help out - pull requests are always appreciated.
I am working on this right now. I'll post a gist soon of how I am going to accomplish this so that I can get feedback. It is actually quite simple, you just need to alias all the columns in the SELECT with the tablename.column.
We could either transfer the column and container values into a map using the aliases as the key before mapping to the types or find a cleaner way.
I have also added FK contraints when you run CreateTable for hood.
Give me a couple days and I will have the basics for joining one to one and one to many relationships up on a gist.
@eaigner @crosbymichael any update on this? Very much desired (although what I need -- eager loading a bunch of records -- might be more compolicated than a single belongs_to relationship.).
In Rails / ActiveRecord, you can do: User.where(...).all(include: {account: :subscription})
This lets you get a bunch of records with minimal SQL.
+1
I'm sorry, but I'm currently not longer actively maintaining hood (moved on to jet for more flexibility).
If anyone want's to jump in, I can add you as a contributor.
Nobody add support?