|
Apparently, $orderby (and therefore cursor.sort()) accept an array (as well as the more usual object-based sort specification):
> db.foo.find().sort("")
|
error: {
|
"$err" : "Can't canonicalize query: BadValue sort must be object or array",
|
"code" : 17287
|
}
|
> db.foo.find().sort([])
|
{ "_id" : ObjectId("54ffd9def90b9eca96351c11") }
|
{ "_id" : ObjectId("554acc2f0141860a26d4784d") }
|
{ "_id" : ObjectId("554c3d70c96e4d4352323672") }
|
{ "_id" : ObjectId("554c3da5c96e4d4352323673") }
|
{ "_id" : ObjectId("554c3db2c96e4d4352323674") }
|
However, the documentation pages for $orderby and cursor.sort() only mention the traditional object notation, eg. db.foo.find().sort( { _id: 1 } ).
It would be good if the docs could explain that the array notation is possible, and how to use it (i.e. what should be inside the array, and how it's interpreted).
|