我正在尝试在集合中查找文档,按日期排序。这行得通,但是我null
在底部的日期字段中获得了文档,我首先想要这些。
MyModel.find({ }, null, { sort: { date: -1 } }, function(err, models) {
// Models sorted with the "largest" date first and models with null dates last
});
如果我将排序更改为{ date: 1 }
我确实首先获得了文档null
,但否则顺序是相反的,这是我不想要的。
我怎样才能实现所需的行为?