[BUG] TypeORM repositories are not initialized in some situations
See original GitHub issueInformation
- Version: 6.38.2
- Packages:
Example
- Build environment for testing
git clone https://github.com/yuki-takei/tsed-typeorm-undefined-repository.git cd tsed-typeorm-undefined-repository yarn
- Modify
src/index.ts
and switch server modules- You can switch 3 kinds of servers. Activate one of them.
import {Server} from "./server-works-well"; // import {Server} from "./server-not-work1"; // without name property // import {Server} from "./server-not-work2"; // without $onReady() process
- You can switch 3 kinds of servers. Activate one of them.
- Launch server
yarn dev
- Go to
http://localhost:8080/hello
What happens?
src/server-works-well.ts
- This works fine.
UserRepository
instance will be initialized correctly and you will see the messageUser count is 0
- This works fine.
src/server-not-work1.ts
UserRepository
instance will not be initialized.- The server returns 500 with the message
Cannot read property 'count' of undefined
src/server-not-work2.ts
UserRepository
instance will not be initialized.- The server returns 500 with the message
Cannot read property 'count' of undefined
What is the expected result?
UserRepository
instance will be initialized correctly even without name property in ConnectionOptions or withoutthis.injector.get<TypeORMService>(TypeORMService);
process.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Typesafe entity initialization does not work with TypeOrm 0.3.6
Having any entity that uses a constructor while using the latest version of TypeOrm (0.3.6) will trigger the bug while the database ...
Read more >Connection "default" was not found with TypeORM
You are trying to create a repository or manager without the connection being established. Try doing this const shopkeeperRepository ...
Read more >no metadata for - You.com | The AI Search Engine You Control
Am I doing something wrong or is there a bug in typeorm? Open side panel. NestJS EntityMetadataNotFoundError: No metadata for "Repository" was found....
Read more >TypeORM - Amazing ORM for TypeScript and JavaScript (ES7 ...
Supports both DataMapper and ActiveRecord (your choice). Entities and columns. Database-specific column types. Entity manager. Repositories and custom ...
Read more >NestJS, TypeORM and PostgreSQL — full example ... - Medium
In this example we'll work on a simple NodeJS API that is powered by a PostgreSQL database for data storage and setup some...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I sent you a PR. You’ve missed the import of typeorm. It’s really important to keep it.
I added a warning on the documentation: https://tsed.io/tutorials/typeorm.html#installation
See you Romain
@Romakita Hi. I made #1334. Please review it and feedback.
Regards,