class Comment
include MongoMapper::Document
scope :by_rating, lambda { |minimum| where(:rating.gte => minimum) }
key :rating
belongs_to :user
end
class User
include MongoMapper::Document
many :comments
end
User.first.comments.by_rating(3)
最后一行的查询实际上是做什么的?MongoMapper 是否足够智能以仅执行一个带有两个 WHERE 条件(user_id 和最低评分)的查询?