我正在为 MongoDB 创建分步请求。一切正常,但 Mongo 无法识别排序选项。我做错了什么?
var request = {}
request['show'] = 1;
request['category'] = category;
switch (sort) {
case "new_first":
request['sort'] = "[['time_added', -1]]";
break;
case "old_first":
request['sort'] = "[['time_added', 1]]";
break;
}
collection.find(request, function(err, posts) {
....
谢谢!