Say I have two data mapper classes like this:
class Family
include DataMapper::Resource
property :id, Serial
property :nice, Boolean
end
Class Person
include DataMapper::Resource
property :id, Serial
belongs_to :family
end
If I want to get all the people belonging to a certain family family
, I can use this:
people=Person.all(:family=>family)
But what if I want to get all people who belong to a family which have the nice
attribute? In SQL I could do
SELECT * FROM persons, families WHERE persons.family_id=families.id AND families.nice
Is there a nice way to do this in data mapper without dropping to the underlying dataset?