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

Optional limit
Type : number
Decorators :
@IsOptional()
@IsInt()
@ApiPropertyOptional({description: 'Limits the number of displayed elements', example: 10})

Limits the number of displayed elements.

Optional offset
Type : number
Decorators :
@IsOptional()
@IsInt()
@ApiPropertyOptional({description: 'Offset from the start of the list of hits', example: 0})

Offset from the start of the list of hits.

Optional order
Type : string
Decorators :
@IsOptional()
@IsString()
@ApiPropertyOptional({description: 'Indicates in which order elements need to be displayed', example: 'asc'})

Indicates in which order elements need to be displayed.

query
Type : string
Decorators :
@IsDefined()
@IsNotEmpty()
@IsString()
@ApiPropertyOptional({description: 'Given query string to perform the search on', example: 'Particle Accelerator'})

Given query string to perform the search on.

import { ApiExtraModels, ApiPropertyOptional } 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()
    @ApiPropertyOptional({
        description: 'Given query string to perform the search on',
        example: 'Particle Accelerator',
    })
    query: string;

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

    /**
     * Offset from the start of the list of hits.
     */
    @IsOptional()
    @IsInt()
    @ApiPropertyOptional({
        description: 'Offset from the start of the list of hits',
        example: 0,
    })
    offset?: number;

    /**
     * Indicates in which order elements need to be displayed.
     */
     @IsOptional()
     @IsString()
     @ApiPropertyOptional({
         description: 'Indicates in which order elements need to be displayed',
         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.limit = limit;
        this.order = order;
    }
}

results matching ""

    No results matching ""