Skip to content

Commit 2f54364

Browse files
Merge pull request #2177 from ppodds/patch-1
docs(sql): add @nestjs/typeorm issue 86 solution
2 parents 830e839 + 65996dc commit 2f54364

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

content/techniques/sql.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,16 @@ export class AppModule {}
529529

530530
> warning **Notice** If you don't set the `name` for a data source, its name is set to `default`. Please note that you shouldn't have multiple connections without a name, or with the same name, otherwise they will get overridden.
531531
532+
> warning **Notice** If you are using `TypeOrmModule.forRootAsync`, you have to set the data source name outside `useFactory`. For example:
533+
> ```typescript
534+
> TypeOrmModule.forRootAsync({
535+
> name: 'albumsConnection',
536+
> useFactory: ...,
537+
> inject: ...,
538+
> }),
539+
> ```
540+
> See [this issue](https://github.com/nestjs/typeorm/issues/86) for more details.
541+
532542
At this point, you have `User` and `Album` entities registered with their own data source. With this setup, you have to tell the `TypeOrmModule.forFeature()` method and the `@InjectRepository()` decorator which data source should be used. If you do not pass any data source name, the `default` data source is used.
533543
534544
```typescript

0 commit comments

Comments
 (0)