I have a model that has several belongs-to fields. Is there a way to order by a field in the belongs to model? For example:
<model name="model_1" label="Model 1"> <belongs-to model="model_2" /> <belongs-to model="model_3" /> <belongs-to model="model_4" /> </model>
I want to be able to do something like the following:
view.order = DB.model_1.all().include('model_2', 'model_3', 'model_4').orderBy('model_2.name').toArray()
I'm wanting to do this to sort the query based off of a nested key/value pair (the model_2 name). Is this possible? Or should I grab the original query (without the
orderBy()) and sort the query from there?