You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
findOne() signature without parameters was dropped.
If you need a single row from the db you can use a following syntax:
const [user] = await userRepository.find()
This change was made to prevent user confusion.
See typeorm/typeorm#2500 for details.
findOne(id) signature was dropped. Use following syntax instead:
const user = await userRepository.findOneBy({
id: id // where id is your column name
})
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 :)
The text was updated successfully, but these errors were encountered:
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:
changed the id parameters type from string to number from my coffee.controller.ts and coffee.service.ts
In the coffee.service.ts::CoffeesService.findOne() I changed the use of findOne(id); to findOneBy({id});
The resulting function was
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 :)
The text was updated successfully, but these errors were encountered: