Pagination in nodejs with mysql

后端 未结 4 844
鱼传尺愫
鱼传尺愫 2021-02-08 10:48

In my project I need to query the db with pagination and provide user the functionality to query based on current search result. Something like limit, I am not able to find anyt

4条回答
  •  梦如初夏
    2021-02-08 11:27

    Was looking for a quick solution. maybe would be useful for someone.

    SELECT id  FROM complexCoding LIMIT ? OFFSET ?
    ",req.query.perpage,((req.query.page-1) * req.query.perpage)
    

    Do not forget to paginate according to the total count of id divided by perpage

提交回复
热议问题