diff --git a/src/pagination.dto.ts b/src/pagination.dto.ts index fbdd2e1..5c06ec3 100644 --- a/src/pagination.dto.ts +++ b/src/pagination.dto.ts @@ -6,10 +6,10 @@ export class PaginationDto { @IsNumber() @Type(() => Number) @Min(1) - page?: number = 1; + page?: number; @IsOptional() @IsNumber() @Type(() => Number) @Min(1) - limit?: number = 1; + limit?: number; } diff --git a/src/shows/shows.service.ts b/src/shows/shows.service.ts index 76189f8..dc92c32 100644 --- a/src/shows/shows.service.ts +++ b/src/shows/shows.service.ts @@ -14,11 +14,8 @@ export class ShowsService { } async findAll(page: number, showsPerPage: number): Promise { - // Default value is 1 and I can't think any reason why you would want - // a single item per page, so if showsPerPage is 1 then just don't do - // any pagination at all let shows; - if (showsPerPage != 1) { + if (showsPerPage !== undefined) { const skip = (page - 1) * showsPerPage; shows = await this.showModel.find().skip(skip).limit(showsPerPage); } else {