Mongo对象没有方法排序'

时间:2015-10-31 23:11:30

标签: javascript mongodb api

Accounts = new Mongo.Collection('accounts');

(账户报表)

var accountPhone = {'phoneNum': phoneNum};
if (Accounts.find(accountPhone).sort({$natural:-1}).limit(1)) {

(发出错误的行,在POST调用中调用)

当我打电话时,我得到了这个

TypeError: Object [object Object] has no method 'sort'
    at Object.Api.addRoute.post.action (okey-api2.js:98:51)
    at Route.Route._callEndpoint (packages/nimble_restivus/packages/nimble_restivus.js:318:1)
    at packages/nimble_restivus/packages/nimble_restivus.js:209:1
    at packages/simple_json-routes/packages/simple_json-routes.js:53:1

1 个答案:

答案 0 :(得分:0)

看起来像Meteor。如果是,请尝试sortlimit选项:

Accounts.find(accountPhone, {
    sort: {
        $natural: -1
    },

    limit: 1
})

链接到docs