Skip to content

CountOptions are not included in PaginateOptions #73

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

Open
pbatr opened this issue Oct 11, 2024 · 2 comments
Open

CountOptions are not included in PaginateOptions #73

pbatr opened this issue Oct 11, 2024 · 2 comments

Comments

@pbatr
Copy link

pbatr commented Oct 11, 2024

We are running into the problem that totalCount is wrong when using paginate with inner joins (most likely only with many-to-many relations but did not dig deeper). A workaround is to pass distinct: true parameter to .paginate() because since 401972b the query args are passed also to .count() and that fixes the issue. But now typescript is complaining because .paginate() only takes FindOptions and that type does not include distinct.

I would suggest to either update the type to include also CountOptions or include distinct: true in totalCountQueryOptions and cursorCountQueryOptions.

@duncanhoggan
Copy link

I'm also having this issue, would be a great addition

@Kaltsoon
Copy link
Owner

Did I understand correctly, that including dinstinct?: boolean to PaginateOptions type and passing the distinct to the count query would work in this case?

export interface PaginateOptions<ModelType extends Model>
  extends FindOptions<Attributes<ModelType>> {
  after?: string;
  before?: string;
  distinct?: boolean; 
}

This sounds like an escape hatch for the problem. Would be nice to find and solve the root problem.

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

No branches or pull requests

3 participants