Reputation: 31
I want to use pagination in express with MySQL database. I have read many more posts for use pagination in express but did not find any post to solve my problem. I have found the post which use in pagination in express with monogodb but I want with MySQL.
Upvotes: 0
Views: 2407
Reputation:
Use LIMIT
and OFFSET
while querying your data.
For example, to get the first 30 data, you use
SELECT * FROM DATA LIMIT 30;
And to get the second page, use
SELECT * FROM DATA LIMIT 30 OFFSET 30;
In your Express app, make page as one of the params you process in the API logic. That simple.
Upvotes: 5