views:

13

answers:

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

What does the query on last line actually do? Is MongoMapper intelligent enough to execute only one query with two WHERE conditions (user_id and minimum rating)?