Skip to content
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

Loading Relations #47

Open
robfig opened this issue Feb 2, 2013 · 6 comments
Open

Loading Relations #47

robfig opened this issue Feb 2, 2013 · 6 comments

Comments

@robfig
Copy link

robfig commented Feb 2, 2013

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?

@eaigner
Copy link
Owner

eaigner commented Feb 2, 2013

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.

@crosbymichael
Copy link

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.

@cypriss
Copy link

cypriss commented Jul 3, 2013

@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.

@FreekKalter
Copy link

+1

@eaigner
Copy link
Owner

eaigner commented Dec 9, 2013

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.

@weldpua2008
Copy link

Nobody add support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants