MongoDB 给 sort 传参,不能排序

Unknow user · July 11, 2014 · Last by johnliu replied at July 11, 2014 · 7467 hits

var item = options.mDataProp_; this.find(criteria) .sort({item: options.sSortDir_0}) .limit(options.perPage) .skip(options.perPage * options.page) .exec(cb)

item 是我传给 sort 的参数,打印出来是数据库中的字段,但就是不能排序。把打印出来的值,直接写在 sort 就可以排序。

options.sSortDir_0 是多少?0 吗

可用的输入项应该是 1 或者 -1 吧

Unknow user #2 July 11, 2014

@wongyouth desc asc

You need to Sign in before reply, if you don't have an account, please Sign up first.