DEV Community

Discussion on: Pagination in an API: page number vs start index

Collapse
 
joaofbantunes profile image
João Antunes

Nice!

I would say that's an upgraded version of number 2, as you're using something that can be indexed in the database rather than a usually generated in query time index.

One question though, if you fetch by date then limit, how do you get the remainder entities for that date? Or is this not relevant in your case?

Collapse
 
sudiukil profile image
Quentin Sonrel

For now I'd say it's not relevant because it's actually not dates but datetimes (including seconds), so most entities should have a unique datetime, so remainders after applying the limit are quite unlikely to happen. This API is still in early stages of development and is not fully tested so I might have missed some issues though 😅

Thread Thread
 
joaofbantunes profile image
João Antunes • Edited

Got it, so you could just use the datetime of the last one, and get the rest from there 👍

Thread Thread
 
sudiukil profile image
Quentin Sonrel

Exactly :)