src/common/dtos/page-options.dto.ts
Properties |
Accessors |
Readonly Optional order |
Type : Order
|
Default value : Order.ASC
|
Decorators :
@ApiPropertyOptional({enum: Order, default: undefined})
|
Defined in src/common/dtos/page-options.dto.ts:13
|
Readonly Optional page |
Type : number
|
Default value : 1
|
Decorators :
@ApiPropertyOptional({minimum: 1, default: 1})
|
Defined in src/common/dtos/page-options.dto.ts:23
|
Readonly Optional take |
Type : number
|
Default value : 10
|
Decorators :
@ApiPropertyOptional({minimum: 1, maximum: 50, default: 10})
|
Defined in src/common/dtos/page-options.dto.ts:35
|
skip |
getskip()
|
Defined in src/common/dtos/page-options.dto.ts:37
|
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsInt, IsOptional, Max, Min } from 'class-validator';
import { Order } from 'common/constants';
export class PageOptionsDto {
@ApiPropertyOptional({
enum: Order,
default: Order.ASC,
})
@IsEnum(Order)
@IsOptional()
readonly order?: Order = Order.ASC;
@ApiPropertyOptional({
minimum: 1,
default: 1,
})
@Type(() => Number)
@IsInt()
@Min(1)
@IsOptional()
readonly page?: number = 1;
@ApiPropertyOptional({
minimum: 1,
maximum: 50,
default: 10,
})
@Type(() => Number)
@IsInt()
@Min(1)
@Max(50)
@IsOptional()
readonly take?: number = 10;
get skip(): number {
return (this.page - 1) * this.take;
}
}