Perhaps you can use aggregation and an artificially high end date:
c = db.foo.aggregate([
{$project: {
next_time: 1,
nlt: { $ifNull: [ "$next_time", new ISODate("9000-01-01") ] }
}
}
,
{$sort: { "nlt": 1}}
]);
c.forEach(function(r) { printjson(r); });
Alternatively, if the majority of the material has nulls and you don't want to deal with those docs at all, then filter them out and just $sort
the remainder:
db.foo.aggregate([
{$match: {"nt": {$exists: true}}}
,
{$sort: { "nt": 1}}
]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…