'nestjs/crud Passing Filter conditions from a controller to a service but CrudRequest type
I am using nestjsx/crud to control my API endpoints, and I would like to call another service from an existing controller as I would like to receive a set of tags back which I will then do more processing on.
The controller that will return me back the tags:
@Crud({
model: {
type: Test,
},
})
@Controller("test")
export class TestController implements CrudController<Test> {
constructor(public service: TestService) {}
get base(): CrudController<Test> {
return this;
}
@Override()
getMany(
@ParsedRequest() req: CrudRequest,
) {
return this.base.getManyBase(req);
}
}
I then have this controller which calls the getMany endpoint and then does some work with the results.
@Get('gettest')
getTest( @ParsedRequest() req: CrudRequest ) {
const results = this.testService.getMany( {
filter: [ { field: 'name', operator: 'eq', value: 'Justin' } ],
});
//
// Do more processing with the results
//
}
The issue I am experiencing is passing the filter parameter into the getMany as it is of type CrudRequest, so I am getting this message:
Object literal may only specify known properties, and 'filter' does not exist in type 'CrudRequest'
I have tried a number of different options and this was a project using nestjsx/crud 2.x so have moved it to latest but cannot find any material on the best way of passing filter information between services.
Does anyone know what the best way of doing this is?
Many thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
