Meteor查询排序错误“Requests.find(...)。排序不是函数”

时间:2017-08-01 10:31:06

标签: meteor minimongo

我需要对“datetime”升序格式进行排序。但得到错误“Requests.find(...).sort is not a function”meteor mini mongo find

var results = Requests.find({
    "sp_id": request.sp_id,
    "slot": request.slot,
    "date": request.date,
    "datetime": {
        '$gte': request.datetime
    },
    "status": {
        $nin: ['cancel', 'completed']
    }
}
).sort({datetime: 1}).fetch();

console.log(results);

感谢。

1 个答案:

答案 0 :(得分:3)

语法为:

const query = { your: 'query' };
const options = { sort: { datetime: 1 } };

const results = Requests.find(query, options).fetch();

查看docs