3 ms·
I don't use Nest or have strong feelings about it, but this bit stuck out: > TypeORM is not even typed. When you run a .findOne() method is just passes back a
by bastawhiz 3y ago
I don't use Nest or have strong feelings about it, but this bit stuck out:
> TypeORM is not even typed. When you run a .findOne() method is just passes back a generic.
This is patently false. I'm not sure what the author is even trying to say here, but the output of `Foo.findOne(...)` is `Promise<Foo | null>`. If it's not, there's a good chance you're coloring outside the lines. Maybe this is true in the context of NestJS, but it is not true for typeorm on its own.
- itslennysfault 3y agoI thought the same. It's not true with TypeORM in Nest either. If you're using DI it's basically impossible in Nest. constructor( // this is the only way to get a repository for the photo table/model private photoRepository: Repository<Photo>, ) { } getPhoto() { // this would be type Photo const photo = this.photoRepository.findOne(); }
- beart 3y agoYou can inject a TypeORM data source which is non typed and create a query builder, but as pointed out, it's opt in.