我有这样的模型
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 个房间,但我不知道从哪里开始。
也许有地图/减少的东西?