UNPKG

mongodb-dynamic-api

Version:

Auto generated CRUD API for MongoDB using NestJS

22 lines (21 loc) 866 B
import { Type } from '@nestjs/common'; import { PipelineStage } from 'mongodb-pipeline-builder'; import { DeleteResult } from './dynamic-api-route-response.type'; interface Mappable<Entity> { toEntity?: <DTO = any>(body: DTO) => Partial<Entity>; toEntities?: <DTO = any>(body: DTO) => Partial<Entity>[]; fromDeleteResult?: <Presenter = any>(result: DeleteResult) => Presenter; fromEntity?: <Presenter = any>(entity: Entity) => Presenter; fromEntities?: <Presenter = any>(entities: Entity[]) => Presenter[]; fromAggregate?: <Presenter = any>(entities: Entity[], count: number, totalPage: number) => Presenter; } interface Aggregatable<Query> { toPipeline?: (query: Query) => PipelineStage[]; } type DTOsBundle = { query?: Type; param?: Type; body?: Type; presenter?: Type; }; export { Aggregatable, DTOsBundle, Mappable };