私はこのようなモデリングを持っています
class Room
include Mongoid::Document
field :name, type: String
has_many :messages
end
class Message
include Mongoid::Document
field :content, type: String
belongs_to :room
end
過去 24 時間に最も多くのメッセージを受け取った上位 3 つのルームを見つける必要がありますが、どこから始めればよいかわかりません。
多分map/reduceで何か?