pilagod / gorm-cursor-paginator

A paginator doing cursor-based pagination based on GORM
https://github.com/pilagod/gorm-cursor-paginator
MIT License
188 stars 44 forks source link

Cursor direction encoded as part of a cursor #67

Open Virviil opened 1 month ago

Virviil commented 1 month ago

Is there any reason why it's not implemented?

Why should I provide my after or before cursor calling right function, instead of just providing A CURSOR which has the info about if it goes forward or backward?

cursor := p.Paginate(....)
{
   after: base64encode([after, after_cursor_data])
   before: base64encode([before, before_cursor_data])
}

Now after i get cursor from api, i just provide it as_is:

opts = append(opts, paginator.WithCursor(cursor))

which is parsed internally to get information about if it's after or before.

pilagod commented 17 hours ago

This issue @sashahilton00 and I also discussed in the pull request https://github.com/pilagod/gorm-cursor-paginator/pull/66#issuecomment-2292405264.

Appreciate for your feedbacks on this topic 🙌 and I would like to collect more thoughts from the community, since this change would introduce a new mindset to use this library, which is quite different from the old days.