我试图计算查询的所有数据以及获取有限的数据(用于分页)但是控制台输出都给了我计数。 我做错了什么 请帮忙
const curFind = fbUser.find(find, 'firstName gender age birthday facebookId profileURL email imageUrl preferences blocked flames likes rejects location reported')
curFind.count(function(e, count) {
console.log(count);
curFind.skip(0).limit(10).hint( { $natural : 1 } ).exec(function(err, data) {
console.log(data);
});
});
答案 0 :(得分:1)
如果您在执行curFind
之前和之后打印count
对象,您会注意到Query
对象的op
字段从find
更改为{{ 1}}。它可能是也可能不是猫鼬的错误,但解释了为什么你再次计数。我通常不会重复使用查询对象 - 这也可以解决您的问题。