Give the Tag/Photo exemple on DataMapper documentation:
class Photo
include DataMapper::Resource
property :id, Serial
has n, :taggings
has n, :tags, :through => :taggings
end
class Tag
include DataMapper::Resource
property :id, Serial
has n, :taggings
has n, :photos, :through => :taggings
end
class Tagging
include DataMapper::Resource
belongs_to :tag, :key => true
belongs_to :photo, :key => true
end
I want to select all tags that has no photos I know I can do
Tag.select { |tag| tag.photos.size < 1}
But I'd like more Datamapper syntax. Something like
Tag.all :photos.count.lt => 1 #not works
Is there a way to do this? Does anyone knows a nice Datamapper documentation for advanced queries? Documentation at the site is very nice, but too basic.
Tkz