nestjs-typeorm-paginate
nestjs-typeorm-paginate copied to clipboard
feat: implement count query type (RAW|ENTITY)
This allows the query builder to choose a count query type which is counts for RAW or counts for ENTITY when an entity has inner join with many to many relations
ref issue #803 #758
import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { CatEntity } from './entities';
import {
paginate,
Pagination,
IPaginationOptions,
CountQueryTypeEnum,
} from 'nestjs-typeorm-paginate';
@Injectable()
export class CatService {
constructor(
@InjectRepository(CatEntity)
private readonly repository: Repository<CatEntity>,
) {}
async paginate(): Promise<Pagination<CatEntity>> {
return paginate<CatEntity>(this.repository, {
page: 1,
limit: 30,
// default is CountQueryTypeEnum.RAW
countQueryType: CountQueryTypeEnum.ENTITY,
});
}
}
Will this be merged ? I have same problem with N-N relationships and this package.
This solution works for me using TypeORM in a Nest.js project with query builder and joins calculating the correct totalCount.
Please review and merge someone with permissions.
I could also benefit from this change. @bashleigh could you help with this?
@bashleigh is there a chance You can merge this please?
@bashleigh Looking forward to this PR being merged
@bashleigh would also like to get this merged
Sorry it's been a while. I think I prefer this PR out of all the solutions I've seen. Don't suppose you'd mind adding some docs on the readme on how to use it and then I'd be happy to merge it and release as the next minor version