1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

mongooseで指定した範囲だけ取得 | MongoDB

Posted at

mongooseで指定した範囲だけ取得 | MongoDB

やりたいことは、

フロントReact、バックエンドNodeでWebアプリを作ってます。

トップページでページングなり無限スクロールなどしたい。

その場合、getでページ番号を渡して、その件数だけNodeのmongoから取得していくしかない。

skipとlimitで出来る

    var query = Product.find({}).skip(0).limit(5)
    query.exec(function(err,data){
      if (err) throw err;
      res.json(data);
    });

参考

how to set limit,offset,skip in mongoose query

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?