'Why does find method return empty array in typeorm
async create(
gPriceChangeDto: GPriceChangeDto,
gainerEntity: GainerEntity,
): Promise<GPriceChangeEntity> {
const findGPriceChange = await this.gPriceChangeRepository.find();
const priceChange = await this.gPriceChangeRepository.create(
gPriceChangeDto,
);
console.log(findGPriceChange); // []
priceChange.gainer = gainerEntity;
await this.gPriceChangeRepository.save(priceChange);
await this.gPriceChangeRepository.delete(
findGPriceChange?.map((item) => {
return item.id;
}),
);
return priceChange;
}
I have a problem that when I call the find method, it returns an empty array to me. I have a "OneToOne" relation in a file. And in the console I get this error.
[Nest] 8687 - 03/11/2022, 9:47:30 PM ERROR [Scheduler] TypeORMError: Empty
criteria(s) are not allowed for the delete method.
[Nest] 8687 - 03/11/2022, 9:47:30 PM ERROR [Scheduler] TypeORMError: Empty
criteria(s) are not allowed for the delete method. I am using nestjs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
