最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

MongoDB计算并获取有限的数据

IT培训 admin 4浏览 0评论

MongoDB计算并获取有限的数据

我正在尝试计算查询的所有数据,以及获取有限的数据(用于分页),但控制台输出都给了我计数。那是什么我做错了。请帮忙

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);
    });
  });
回答如下:

如果在执行curFind之前和之后打印count对象,您会注意到Query对象的op字段从find变为count。它可能是也可能不是猫鼬的错误,但解释了为什么你再次计数。我通常不会重复使用查询对象 - 这也可以解决您的问题。

MongoDB计算并获取有限的数据

我正在尝试计算查询的所有数据,以及获取有限的数据(用于分页),但控制台输出都给了我计数。那是什么我做错了。请帮忙

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);
    });
  });
回答如下:

如果在执行curFind之前和之后打印count对象,您会注意到Query对象的op字段从find变为count。它可能是也可能不是猫鼬的错误,但解释了为什么你再次计数。我通常不会重复使用查询对象 - 这也可以解决您的问题。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论