src/common/dtos/page-meta.dto.ts
Properties |
|
constructor(undefined: PageMetaParameters)
|
|||||
Defined in src/common/dtos/page-meta.dto.ts:43
|
|||||
Parameters :
|
Readonly hasNextPage |
Type : boolean
|
Decorators :
@ApiProperty({description: 'Flag indicating if there is a next page', example: true})
|
Defined in src/common/dtos/page-meta.dto.ts:43
|
Readonly hasPreviousPage |
Type : boolean
|
Decorators :
@ApiProperty({description: 'Flag indicating if there is a previous page', example: false})
|
Defined in src/common/dtos/page-meta.dto.ts:37
|
Readonly itemCount |
Type : number
|
Decorators :
@ApiProperty({description: 'The number of items in the collection', example: 100, type: 'integer'})
|
Defined in src/common/dtos/page-meta.dto.ts:24
|
Readonly limit |
Type : number
|
Decorators :
@ApiProperty({description: 'The number of items per page', example: 10, type: 'integer'})
|
Defined in src/common/dtos/page-meta.dto.ts:17
|
Readonly page |
Type : number
|
Decorators :
@ApiProperty({description: 'The current page', example: 1, type: 'integer'})
|
Defined in src/common/dtos/page-meta.dto.ts:10
|
Readonly pageCount |
Type : number
|
Decorators :
@ApiProperty({description: 'The number of pages in the collection', example: 10, type: 'integer'})
|
Defined in src/common/dtos/page-meta.dto.ts:31
|
import { ApiProperty } from "@nestjs/swagger";
import { PageMetaParameters } from "./page-meta-parameters.dto";
export class PageMetaDto {
@ApiProperty({
description: "The current page",
example: 1,
type: "integer",
})
readonly page: number;
@ApiProperty({
description: "The number of items per page",
example: 10,
type: "integer",
})
readonly limit: number;
@ApiProperty({
description: "The number of items in the collection",
example: 100,
type: "integer",
})
readonly itemCount: number;
@ApiProperty({
description: "The number of pages in the collection",
example: 10,
type: "integer",
})
readonly pageCount: number;
@ApiProperty({
description: "Flag indicating if there is a previous page",
example: false,
})
readonly hasPreviousPage: boolean;
@ApiProperty({
description: "Flag indicating if there is a next page",
example: true,
})
readonly hasNextPage: boolean;
constructor({ pageOptionsDto, itemCount }: PageMetaParameters) {
this.page = pageOptionsDto.page ?? 1;
this.limit = pageOptionsDto.limit ?? 10;
this.itemCount = itemCount;
this.pageCount = Math.ceil(this.itemCount / this.limit);
this.hasPreviousPage = this.page > 1;
this.hasNextPage = this.page < this.pageCount;
}
}