I have the following models:

Person
has n, :photos

Album
has n, :photos, :through => Resource
has n, :people, :through => :photos, :via => :person

Photo
belongs_to :person, :required => true
has n, :albums, :through => Resource


So here is what I want:

Given an album, I would like all the photos in that album grouped by
the person they belong to. Ideally, I would love to be able to query
an album for all the people in it, and that collection of people would
have ONLY those photos of theirs in the album. After all, the person
probably has a ton of other photos in other albums that are
irrelevant.

I have tried a ton of queries. Some are just syntactically off; others
are not quite right and way too slow anyway. Any insight into a proper
query or in reorganizing my model is really appreciated.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to