Closed Nagell closed 2 years ago
We're currently working on re-recordings of the entire Postgres chapter and will update videos shortly :)
So first of all, apologies to the authors for posting this as the Postgresql bit will change as mentioned in the previous comment...
The error:
src/coffees/coffees.service.ts:20:56 - error TS2559: Type 'string' has no properties in common with type 'FindOneOptions<Coffee>'.
20 const coffee = await this.coffeeRepository.findOne(id);
I faced this today and wasn't a huge deal to fix, nevertheless I lost my focus on the course to find out the reason... not sure if this affects the rest of the samples from the course but this is the way I did it:
id
parameters type from string
to number
from my coffee.controller.ts
and coffee.service.ts
the coffee.service.ts::CoffeesService.findOne()
I changed the use of
findOne(id);
to findOneBy({id});
The resulting function was
async findOne(id: number) {
const coffee = await this.coffeeRepository.findOneBy({id});
... snip snip ...
}
after that I just checked again the console and everything was working as expected again :) BTW, nice course I love it !!!
Hi,
In the chapter 'Add PostgreSQL with TypeORM: Using repository to Access Database' after installing TypeORM in version 0.3 or above the method 'findOne' is no more correct and there is no suggestion which one should be installed. According to TypeORM changelog:
I can imagine that making a new video every time when something changes, would be to much, but some notice in the code below could be helpful :)