猫鼬3.X的抱怨
[]在参数
findOne调用的阵列格式不再支持的参数选择的领域包括。
尝试使用此方法来查找最新的:
Tweet.findOne({}, {}, { sort: { 'created_at' : -1 } }, function(err, post) { console.log( post );});更改
-1到
1找到最古老的。
但是因为您没有使用任何字段选择,所以将几个呼叫链接在一起会更清洁:
Tweet.findOne().sort({created_at: -1}).exec(function(err, post) { ... });甚至将字符串传递给
sort:
Tweet.findOne().sort('-created_at').exec(function(err, post) { ... });


