在 DataMapper 文档中给出Tag/Photo示例:
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
我想选择所有没有照片的标签我知道我可以做
Tag.select { |tag| tag.photos.size < 1}
但我想要更多的 Datamapper 语法。就像是
Tag.all :photos.count.lt => 1 #not works
有没有办法做到这一点?有谁知道用于高级查询的不错的 Datamapper 文档?该站点上的文档非常好,但太基础了。
太极拳