Open gino8080 opened 3 years ago
Hello ,
I would like to understand how to use RequestQueryParser in the controller to make the typeorm query
this is my pseudo code
@Crud({ model: { type: Examination, }, query: { join: { exams: { eager: true, }, user: { eager: true, }, reports: { eager: true, }, "reports.exam": { eager: true, }, }, }, }) @Controller('api/examinations') @ApiTags('examinations') export class ExaminationsController implements CrudController<Examination> { constructor(public service: ExaminationsService) { } get base(): CrudController<Examination> { return this; } //this is a custom controller @UseGuards(JwtAuthGuard) @Post('userExams') async userExams( @Request() req, //need this to get the user from jwt @Body() body: any //sending a RequestQueryBuilder from client ) { const parser = RequestQueryParser.create(); const parsed = parser.parseQuery(body) /* parsed is womething like parsed = { fields: [], paramsFilter: [], filter: [ { field: 'date', operator: '$gte', value: '2021-07-01 00:00' }, { field: 'date', operator: '$lte', value: '2021-07-22 23:59' } ], ... } how to use it in my find method? should I convert / parse before sending to find method */ const data = await this.service.find({ parsed ?!?!? })
any help please?
Hello ,
I would like to understand how to use RequestQueryParser in the controller to make the typeorm query
this is my pseudo code