[英]MongoDB/Mongoose Sort Error
Item.find().sort([['_id','descending']]).limit(15).each(function(doc) {
client.send(JSON.stringify(doc));
});
返回此錯誤:
Error: Error: Illegal sort clause, must be of the form [['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]\n
有任何想法嗎? 謝謝!
Item.find().sort('_id','descending').limit(15).each(function(err, doc) {
client.send(JSON.stringify(doc));
});
嘗試.sort([['_id','desc']])
您也可以嘗試.sort("_id")
但默認為升序。
這應該工作:
Item.find().sort([['_id','1']]).limit(15).each(function(err, doc) {
client.send(JSON.stringify(doc));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.