我使用的是Nodejs和Mongoose。 我的数据库中有134个条目。 当我想从数据库查询中获取所有数据时还没有完成。 没有错误或我得到的任何其他内容。
如果我在查询时添加限制,则数据不会在101st之后出现。
var mongoose = require('mongoose');
var customers = mongoose.model('Customer');
customers
.find({})
.limit(parseInt(request.body.limit, 10))
.exec(function(err, result){
if (err)
response.send(err);
response.send(result);
});
PS:我正在使用localhost,我的系统是Mac OSX(El Capitan)。
答案 0 :(得分:0)
您需要更改像
这样的parseInt函数customers
.find({})
.limit(parseInt(request.body.limit, 10))
.exec(function(err, result){
if (err)
response.send(err);
response.send(result);
});
其中10表示您传递给parseInt的数字的基数。限制在此确保您只获得与传递给它的数字一样多的记录。