0.3.0: Connection "default" was not found for creating entities with dataSource
See original GitHub issueIssue Description
The datasource I’m using:
export const dataSource = new DataSource({
type: "postgres",
url: process.env.DATABASE_URL,
migrations: [path.join(__dirname, "./migrations/*")],
entities: [path.join(__dirname, "./entities/*")],
subscribers: [path.join(__dirname, "./subscribers/*")],
logging: !__prod__,
migrationsRun: true,
synchronize: true,
});
and for a Post entity if I do
dataSource.getRepository(Post).create({...someEntity}).save() (or getTreeRepository)
This will complain that there is no default connection, it does not happen for the other basic methods insert, update, delete etc, I think it will have this problem for other methods like remove though, which aren’t sql methods
Expected Behavior
The post should be created and saved properly along with its tree parent/children if it exists, like in 0.2.x versions
Actual Behavior
Connection "default" was not found
Relevant Database Driver(s)
DB Type | Reproducible |
---|---|
aurora-mysql |
no |
aurora-postgres |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
yes |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✅ No, I don’t have the time, but I can support (using donations) development. 5$
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (9 by maintainers)
Top Results From Across the Web
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 >typeorm metadata not found | The AI Search Engine You Control
My project has 2 seperate connection datasources. One is to a readonly mysql database, the other is a postgres database. Everything on the...
Read more >typeorm/typeorm - Gitter
Does anyone have some insight into how to use @TransactionManager() and @TransactionRepository() without creating typing errors?
Read more >TypeORM - Amazing ORM for TypeScript and JavaScript (ES7 ...
More information on supported column types can be found here. # Creating a new DataSource. Now, when our entity is created, let's create...
Read more >typeorm: CHANGELOG
// load entities, establish db connection, sync schema, etc. await dataSource.connect().
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 am using 0.3.10 still facing same issue.
okay I think I know what is the problem. For now you need to set
YourEntity.useConnection(dataSource)
for each entity you have as a hotfix. I’ll push a PR for this issue.