zf-fr / zfr-rest

A module for Zend Framework 2 that aims to simplify RESTful
81 stars 31 forks source link

Implement cursor based pagination #163

Open bakura10 opened 10 years ago

bakura10 commented 10 years ago

While working on Stripe API a lot, they have implemented a type of pagination I was unaware of: cursor based pagination. The idea is that normal pagination (using limit, offset...) is unreliable because if new records are insreted while you paginate, you may miss records.

Cursor based assume that you pass the last id of the records, so that pagiantion continue just after this record.

I'm not sure if that can be implemented easily in ZfrRest but that would be a nice addition :p.

Ocramius commented 10 years ago

You mean something like start=invoice1234?

bakura10 commented 10 years ago

Exactly. Stripe uses "starting_after" and "ending_before"

bakura10 commented 10 years ago

I think the idea would be to automatically create a criteria that would sort by the id, and having a gt / lt filter.