I use mongoid to store data. I have a scenario where I have to sort my parents by the number of dependents they have. My model is simple:
References to the parent model dependent names stored_as => array
Dependent model reference_many parentsstored_as => array
I do not want to go through my parents, find the number of dependents, store them in an array and upload them to my view.
I need to sort parents by the number of dependents with only one query. Is it possible?
Thank.
Gagan source
share