Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a num_items_and_pages on the paginator #768

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

fistons
Copy link
Contributor

@fistons fistons commented May 26, 2022

This method allows us to get both number of items and pages of a
paginator with only one database query.

Adds

  • Adds a new method on the paginator allowing us to get bot number of pages and items with one request

fistons added 2 commits May 26, 2022 14:34
This method allows us to get both number of items and pages of a
paginator with only one database query.
Comment on lines 87 to 88
/// Get the total number of items and pages in a tuple as (number_of_items, number_of_pages)
pub async fn num_items_and_pages(&self) -> Result<(usize, usize), DbErr> {
Copy link
Member

Choose a reason for hiding this comment

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

Hey @fistons, thanks for the contributions! I'm just thinking would it be better to return a struct with named fields: number_of_items and number_of_pages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sure things!

Copy link
Member

Choose a reason for hiding this comment

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

yeah, two usize can sometimes be confusing

@tyt2y3 tyt2y3 merged commit 5037dc9 into SeaQL:master Jun 30, 2022
@tyt2y3
Copy link
Member

tyt2y3 commented Jun 30, 2022

Thank you all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants