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