A find() with a sort() on a mongos may return an empty result set:
mongos> db.c.insert({x:1}) WriteResult({ "nInserted" : 1 }) mongos> db.c.find() { "_id" : ObjectId("583dc54dade9d2265ce2b196"), "x" : 1 } mongos> db.createView("cView", "c", [{$match : { x : {$gt : 0}}}]) { "ok" : 1 } mongos> db.cView.find() { "_id" : ObjectId("583dc54dade9d2265ce2b196"), "x" : 1 } mongos> db.cView.find().sort({_id:1})
There's a simple workaround, which is to use the aggregation pipeline:
mongos> db.cView.aggregate([{ $sort: {_id:1}}]) { "_id" : ObjectId("583dc54dade9d2265ce2b196"), "x" : 1 }
- is related to
-
SERVER-26765 Move views tests into jsCore
- Closed