2015-02-23 60 views
0

你好我試圖植入MongoDB的LTE功能 http://docs.mongodb.org/manual/reference/operator/query/lte/MongoDB的LTE不起作用

,但它似乎不工作:■ 我的路線:

app.route('/sign/:projectId/:startWeek/:endWeek') 
    .post(sign.readExport); 

控制器:

exports.readExport = function(req, res) { 
    Sign.find() 
     .where('projectId').equals(req.params.projectId) 
     .where('startWeek').gte(req.params.startWeek).lte(req.params.endWeek) 
     .sort('-created') 
     .exec(function(err, sign) { 
      if (err) { 
       return res.status(400).send({ 
        message: errorHandler.getErrorMessage(err) 
       }); 
      } else { 
       res.jsonp(sign); 
      } 
     }); 
}; 

得到了與startWeek一個數據庫對象 「:」 9"

使用郵差我得到這些結果

http://localhost:3000/sign/658/8/8 
//respons null as it should 

http://localhost:3000/sign/658/8/9 
//respons my object as it should 

http://localhost:3000/sign/658/8/10 
http://localhost:3000/sign/658/8/11 
http://localhost:3000/sign/658/8/12... 
//respons null should respons my object ?? 

我做錯了什麼? :)

+0

@JohnnyHK是對的。現在就開始工作了!只是將數值從字符串更改爲數字thx:p你可以發佈它作爲答案:) – Stweet 2015-02-23 13:56:25

回答

1

數字字符串的排序讓你失望。您需要將文檔中的startWeek值更改爲數字而不是字符串。

'10' < '9',但是10 > 9