2016-06-10 167 views
0

我有我的流星應用程序的這個問題。當我將鉻控制檯上運行此查詢,它返回預期的數據 Questions.find({},{排序:{commentLength:-1}})流星MongoDB錯誤

,但是當我在控制檯運行它db.questions.find({}, {sort:{commentLength: -1}})

返回該錯誤

error: { 
    "$err" : "Can't canonicalize query: BadValue Unsupported projection option: sort: { commentLength: -1.0 }", 
    "code" : 17287 
} 

爲什麼會出現這種錯誤發生的呢?謝謝

回答

2

sort在mongodb shell中執行時有不同的語法。試試這個:

db.questions.find().sort({commentLength: -1}) 
+0

Thanks ** David *# – Kenshinman