pagy-cursor icon indicating copy to clipboard operation
pagy-cursor copied to clipboard

Multi column cursor

Open ombr opened this issue 6 years ago • 1 comments

Hi,

With a big database, I am using multiple column ordered indexes in order to return item in order. but the limit/offset is not the best thing to do.

I am interested in generating a cursor from multiple columns like this:

  def self.after(cursor = nil)
    query = reorder('created_at DESC, public_id DESC')
    if cursor.present?
      return query.where(
        'cursors.created_at < ? or (cursors.created_at = ? and cursors.public_id < ?)',
        cursor.created_at,
        cursor.created_at,
        cursor.public_id
      )
    end
    query
  end

Do you have plans to do something like this ? I could help.

ombr avatar Aug 28 '19 14:08 ombr

@ombr I am happy if you would help in this

Uysim avatar Aug 29 '19 12:08 Uysim