company.service.ts:`
async get(id: FindOneOptions<Company>): Promise<Company | null>{
console.log(id)
return await this.companyRespository.findOne(id);
}
company.controller.ts:
@Get(':id')
findOneCompany(@Param('id') id: FindOneOptions<Company>){
return this.companyService.get(id);
}
I have written the following code but whenever I try to get by FindOne my console says that "You must provide selection conditions in order to find a single row.".
I tried all possible solution on the web including adding curly braces and also using other FindOptions nothing seems to make this error go away.
My API platform shows an internal server error.
3
Answers
Try to specify the Entity field that you’re searching by. In your case this is the
id
.company.service.ts
If it’s an id I don’t know why it’s type is an interface. I think that’s why you have vscode telling you that’s an error. You should as @DinuMinhea says:
service.ts
company.controller.ts: