File

src/core/domain/dtos/search-q.dto.ts

Description

Elasticsearch response DTO

Index

Properties

Constructor

constructor(query: string, page: number, limit: number, order: string)

Constructs an object with provided parameters

Parameters :
Name Type Optional
query string No
page number No
limit number No
order string No

Properties

limit
Type : number
Decorators :
@IsOptional()
@IsInt()
@ApiProperty({description: 'limit', example: 10})

Limits the number of displayed elements.

order
Type : string
Decorators :
@IsOptional()
@IsString()
@ApiProperty({description: 'order', example: 'asc'})

Limits the number of displayed elements.

page
Type : number
Decorators :
@IsDefined()
@IsNotEmpty()
@IsInt()
@ApiProperty({description: 'page', example: 3})

Page number to display.

query
Type : string
Decorators :
@IsDefined()
@IsNotEmpty()
@IsString()
@ApiProperty({description: 'query', example: 'Particle Accelerator'})

Given query string to perform the search on.

import { ApiExtraModels, ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsInt, IsNotEmpty, IsOptional, IsString } from "class-validator";

/**
 * List of allowed properties in this DTO
 */
const allowedProperties = ['query', 'pagen', 'limit', 'order'];

/**
 * Elasticsearch response DTO
 */
@ApiExtraModels()
export class SearchQueryDto {
    /**
     * Given query string to perform the
     * search on.
     */
    @IsDefined()
    @IsNotEmpty()
    @IsString()
    @ApiProperty({
        description: 'query',
        example: 'Particle Accelerator'
    })
    query: string;
    
    /**
     * Page number to display.
     */
    @IsDefined()
    @IsNotEmpty()
    @IsInt()
    @ApiProperty({
        description: 'page',
        example: 3,
    })
    page: number;

    /**
     * Limits the number of displayed elements.
     */
    @IsOptional()
    @IsInt()
    @ApiProperty({
        description: 'limit',
        example: 10,
    })
    limit: number;

    /**
     * Limits the number of displayed elements.
     */
     @IsOptional()
     @IsString()
     @ApiProperty({
         description: 'order',
         example: 'asc',
     })
     order: string;

     /**
      * Constructs an object with provided parameters
      * @param query 
      * @param page 
      * @param limit 
      * @param order 
      */
     constructor(query: string, page: number, limit: number, order: string) {
        this.query = query;
        this.page = page;
        this.limit = limit;
        this.order = order;
     }
}

results matching ""

    No results matching ""