Open

Description
I want to be able to use function paginate, but being able to remain my current filters query params.
For instance, I have the following endpoint:
@Get("/")
async index(
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number = 1,
@Query('limit', new DefaultValuePipe(10), ParseIntPipe) limit: number = 10,
@Query('type') type: string,
): Promise<Pagination<Pokemons>> {
limit = limit > 100 ? 100 : limit;
return this.pokemonService.paginate({
page,
limit,
type,
route: 'http://localhost:3000/pokemons',
});
}
As you can see, I have added the option type over there...
But I cannot see this reflected on the links object when browsing in the api.
"links": {
"first": "http://localhost:3000/pokemons?limit=10",
"previous": "",
"next": "http://localhost:3000/pokemons?page=2&limit=10",
"last": "http://localhost:3000/pokemons?page=7&limit=10"
}
I would like to see it for example when applying the query params of type=fire:
"next": "http://localhost:3000/pokemons?page=2&limit=10&type=fire",
interface IOptions extends IPaginationOptions {
type: string
}
async paginate(options: IOptions): Promise<Pagination<Pokemons>> {
const queryBuilder = this.repo
.createQueryBuilder();
if (options.type) {
queryBuilder.where("(type_1 = :type OR type_2 = :type)", { type: options.type })
}
return paginate<Pokemons>(queryBuilder, options);
}
What am I doing wrong here?
Metadata
Metadata
Assignees
Labels
No labels