您好,我正在尝试植入mongodb lte函数http://docs.mongodb.org/manual/reference/operator/query/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的db对象
使用邮递员,我得到了以下结果
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 ??我做错了什么?:)
发布于 2015-02-23 21:57:16
对数字字符串的排序会让你犯错。您需要将文档中的startWeek值更改为数字而不是字符串。
'10' < '9',但是10 > 9.
https://stackoverflow.com/questions/28675254
复制相似问题