Assuming we have multiple documents with the following schema:
{
"_id" : ObjectId("55ec6108794ac3cc530041ac"),
"product": "Product x",
"desc": "Blah Blah Blah",
"prices" : [
{
"price": 12.3,
"is_price_active": false,
},
{
"price": 15.3,
"is_price_active": false,
},
{
"price": 15,
"is_price_active": true,
}
]
}
Is it possible to order the result set according to active price or in the other mean is it possible to order the result based on the last price (since in my case, the active price is always the last price)?
something like this: orderBy('prices.[prices.length - 1].price', 'desc')
Thanks in Advance...