Major - P3
So this is the predicament. I know the embeds_many allows you to embed documents into a parent document. This makes sorting by relations easier. However, I cannot have this, because my objects can be isolated entities. In other words, a contact cannot embed_many leads because a lead can exist independently of a contact.
So the relationship I created is a has_one:
field :reference_number, type: String
It works fine, until I need to sort leads by contact reference number. Then I do not know how this can be done.
In ActiveRecord, you can do this:
But there is no way to sort by relations in Mongoid:
contact_ids = Contact.order('reference_number asc').pluck :id
The above doesn't work. Any idea how to improve this problem?