Skip to content

Comments

feat: add set_page to Paginator#2963

Open
dsgallups wants to merge 1 commit intoSeaQL:masterfrom
dsgallups:dsgallups/set-paginator
Open

feat: add set_page to Paginator#2963
dsgallups wants to merge 1 commit intoSeaQL:masterfrom
dsgallups:dsgallups/set-paginator

Conversation

@dsgallups
Copy link

@dsgallups dsgallups commented Feb 20, 2026

This is a really small QoL change for Paginator. We add a method to set the current page via PaginatorTrait::set_page.

This is useful in where you need to start at a page, and then continue fetch_and_nexting your way to glory.

Currently, you need to something like

let mut paginator = some::Entity::find().paginate(db, page_size);

while paginator.cur_page() < start_at_page {
  paginator.next()
}

And while this is workable, it would be ideal to just start at the page you need:

let mut paginator = some::Entity::find().paginate(db, page_size);
paginator.set_page(start_at_page);

This is quite useful for cases where you need to jump around for different pages up to a point and whatnot. Thanks 🙂

}

/// Set the page counter
pub fn set_page(&mut self, page: u64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&mut self -> void or self -> self? @tyt2y3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants