question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeOrmModule.forRoot() should accept connection name

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

TypeOrmModule.forRoot('default') is throwing as invalid code even though in the documentation states that it accepts the same arguments as createConnection() does in Typeorm.

[{
  "name": "default",
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "",
  "password": "",
  "database": "",
  "entities": ["src/**/**.entity{.ts,.js}"],
  "synchronize": false,
  "migrationsTableName": "migrations",
  "migrations": ["src/database/migrations/*{.ts,.js}"],
  "cli": {
    "migrationsDir": "src/database/migrations"
  }
}, {
  "name": "seed",
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "",
  "password": "",
  "database": "",
  "entities": ["src/**/**.entity{.ts,.js}"],
  "synchronize": false,
  "migrationsTableName": "seeds",
  "migrations": ["src/database/seeds/*{.ts,.js}"],
  "cli": {
    "migrationsDir": "src/database/seeds"
  }
}]

Expected behavior

It should pick the connection name from your ormconfig.js or json file like Typeorm does.

What is the motivation / use case for changing the behavior?

To stay up to date with Typeorm’s codebase.

Environment


Nest version: 5.7.3

 
For Tooling issues:
- Node version: 10.5.0  
- Platform:  Mac 

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:28
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
joaogoliascommented, Oct 27, 2020

+1 for connection name support

10reactions
kevinelliottcommented, May 23, 2020

Any update here? I’m seeing some oddities around this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nestjs - Typeorm custom connection name - Stack Overflow
forRootAsync For TypeOrmModule.forRoot if works! Is there any different way to indicate the connection name? I need to add another connection ...
Read more >
Database | NestJS - A progressive Node.js framework
To begin using the User entity, we need to let TypeORM know about it by inserting it into the entities array in the...
Read more >
NestJS Multiple DB Setup with TypeORM - Level Up Coding
Following NestJS docs we will find the connection options example credentials directly set on code. ... @Module({ imports: [ TypeOrmModule.forRoot({
Read more >
Getting started with continuous integration for Nest.js APIs
Configuring and connecting Nest.js to the database ... export class CreateProductDTO { @IsString() name: string; @IsString() description: ...
Read more >
Multiple Databases | Nestjs-query - Blog
forRoot (environment), TypeOrmModule.forRoot({ // name: MUSIC_DB_CONNECTION, // if you leave this out, this will be the "default" connection! type: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found