paginated
This a simple one just confused, in making paginated APIs how do I know where to add the next property so the frontend developer knows it has a next page...how do I check where the next is going to be a + 1 or it's going to be null, in a database,
4 Replies
is it a big db?
and is the limit per page dynamic or static?
cause you can simply COUNT the elements divide by the limit of results per request and send back that number as the total number of pages there are
the response can look like that
If it's too large a dataset to COUNT, set your limit to
per_page + 1
, then pop the last result offyeah that's why I asked the size of the db, COUNT can be slow if you have like...millions of rows
but if you're not at that point COUNT + indexes is fine
Sorry I never replied, was off