I have a model like this:

class Artist
    include DataMapper::Resource
    property :id, Serial
    property :artistname, String, :length => 512
    has n, :tracks, :through => Resource
end

class Track
    include DataMapper::Resource
    property :id, Serial
    property :title, String, :length => 512
    has n, :artists, :through => Resource
end

I want to get all tracks that belongs to an artist and select the
track title along with the artistname:
tracks = Artist.get(params[:id]).tracks

This gives me the track objects belonging to the artist, but how do I
get the artistname?

I could do a second query to fetch this (artist =
Artist.get(params[:id])) but that seems unnecessary.

Any hints appreciated.

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