Kaltsoon / sequelize-cursor-pagination

➡️ Cursor-based pagination queries for Sequelize models
87 stars 27 forks source link

CountOptions are not included in PaginateOptions #73

Open pbatr opened 3 weeks ago

pbatr commented 3 weeks ago

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 https://github.com/Kaltsoon/sequelize-cursor-pagination/commit/401972bdcfc87e8c07658c234c6cc150b46f1888 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 commented 3 weeks ago

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