Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ChappIO46977yI like the way wikidata does it. You request X items after Y where Y is the id of the item you saw last
-
ChappIO46977y@theElectron that would definitely make it easier yes. Then again, any good pagination solution will require some sort of implementation
-
Voxera115857y@theElectron there often are some sequential uuid available and if not you could add an identity column just for sorting and pagination.
If you need pagination on random sort order and cannot keep a snapshot, there probably are no solution that completely avoids occasional reappearance or lost rows depending on which is more damaging. -
sagar131017ySorting by _id in mongodb is quick and guarantees order of insertion of elements. You can use that and limit
-
Voxera115857y@sagar13 you right ;)
Missed the mongodb tag, yes mongodb uids are sequential since they include the current date, time, a machine specific counter and if I remember correctly parts of the mac address yo guarantee uniqueness between machines. -
@sagar13 yes that's useful. But we have been using parse framework(that's one abomination in face of god) And that mutherfucker manages its own _I'd depriving me of that happiness too :/
Related Rants
How do you folks handle your pagination at backend?
I was initially using skip and limit. But that is prone to error.
Then I thought about using last sent items id and using its created_at time and fetching rows/documents after that. But that too is prone to error ( more than one can have same timestamp) hence either having data repeats or data That gets missed.
What is your goto strategy for pagination?
question
node
sql
pagination
mongodb