0

I've been looking for (on npm) pagination plugins for SQLite and Express, since I have an app that lists items using those plugins, but I did not find anything. If someone knows any express plugin that works with SQLite, I appreciate it.

Roberto
  • 1
  • 5
  • Sorry, SO is not an advice forum. "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam." – Soviut Sep 10 '17 at 23:32
  • Pagination doesn't require a particular library, you just use offsets and limits in your database queries. – Soviut Sep 10 '17 at 23:33
  • Thanks, I'm new user at SO. I promise to read in my spare time the SO.Policies – Roberto Sep 11 '17 at 00:19

1 Answers1

4

Pagination doesn't require a particular library, you just use offsets and limits in your database queries.

SELECT * FROM items LIMIT 25

The above query will only get the first 25 records from the items table.

SELECT * FROM items OFFSET 50 LIMIT 25

The above query will start at the 50th record, then get 25 more records after that.

That is the basis for all pagination. You supply an offset usually pageNumber * pageSize and a limit pageSize.

Soviut
  • 88,194
  • 49
  • 192
  • 260
  • OK, I'll try it. I was confused because there are many Pagination's libraries for express on npm (where I usually look for improved solutions, and avoid "reinventing the wheel") Anyway, thank you very much! – Roberto Sep 11 '17 at 00:21
  • If that's the case, you should pick one, try to get it working and then come back here if you run into any issues. Recommending libraries is heavily opinion-based and the suggestions can quickly go out of date. – Soviut Sep 11 '17 at 02:01
  • This might [become inefficient](https://stackoverflow.com/questions/14468586/efficient-paging-in-sqlite-with-millions-of-records). – CL. Sep 11 '17 at 08:06
  • @CL. it's the standard way of doing pagination so UNTIL it becomes inefficient, it isn't a problem. Don't prematurely optimize if you don't have to. – Soviut Sep 11 '17 at 15:04