0

I am looking at implementing UUID'd in place of auto-increment id and was wondering if or how I might integrate cursor based pagination with UUID's.

With simple auto-increments I can simply add/subtract on the current ID to find my next/previous but this is not possible with UUID's.

Would it make more sense to use the cursor on a timestamp column suck as created_on / modified_on?

I am working with Laravel 4, PhpLeague\Fractal (https://github.com/thephpleague/fractal) and am looking at bringing in Rhumsaa\Uuid (https://github.com/ramsey/uuid)

John Slegers
  • 45,213
  • 22
  • 199
  • 169
Mark Kendall
  • 129
  • 2
  • 10

1 Answers1

1

Ideal would be to have a column with automatic datetime/timestamp and use that as an cursor target. Do keep in mind however to have proper index on that field.

Belda
  • 599
  • 2
  • 7
  • 17
  • 1
    What if some users insert at the same time? – Mohsen May 01 '17 at 11:01
  • 1
    What I did was used timestamp and UUID both to generate cursor. Then when needed I could decode using that timestamp and also UUID and use it in query so that my cursor is always unique – Yalamber Dec 19 '17 at 07:09