Dear guys,
I have the following model:
class Message
include Mongoid::Document
include Mongoid::Timestamps
field :conversation_id, :type => String
end
So if I do:
Message.all.order_by(:created_at, :desc).distinct(:conversation_id)
I am hoping that the array which contains ``conversation_id``s could preserve the order from the result of ``Message.all.order_by(:created_at, :desc)`` But as I tested, it seems that the result of distinct will is in an order like (:id, :asc). Is there a recommended way to do that?