Can I sort documents in reversed natural order using aggregation framework?
With the query framework I can specify:
db.solarSystem.find().sort({$natural: -1}).limit(5).pretty()
Thanks.
Can I sort documents in reversed natural order using aggregation framework?
With the query framework I can specify:
db.solarSystem.find().sort({$natural: -1}).limit(5).pretty()
Thanks.
I was going to answer that you can with the following.
{ $sort : { $natural : -1 } }
should be a valide pipeline stage.
But I tested it with the following minimal example:
> var sort = { '$sort' : { '$natural' : -1 } } > var pipeline = [ sort ] > db.test.aggregate( pipeline )
But I got:
"errmsg" : "FieldPath field names may not start with '$'.",