Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention exporting repository providers in the Techniques/Database #611

Merged
merged 1 commit into from
Sep 4, 2019

Conversation

mayorandrew
Copy link
Contributor

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[X] Other... Please describe:

Description

In @nestjs/core version before 6.3 you could inject typeorm repositories by importing a module which imports TypeOrmModule.forFeature, like so:

@Module({
  imports: [ TypeOrmModule.forFeature([ Photo ]) ]
})
export class PhotoModule {}
@Module({
  imports: [ PhotoModule ],
  providers: [ PhotoService ]
})
export class PhotoHttpModule {}
@Injectable()
export class PhotoService {
  constructor(@InjectRepository(Photo) private readonly photoRepo: Repository<Photo>) {}
  ...
}

Since version 6.3 you need to explicitly export typeorm repositories from PhotoModule. You can do that by exporting the whole TypeOrmModule module, like so:

@Module({
  imports: [ TypeOrmModule.forFeature([ Photo ]) ],
  exports: [ TypeOrmModule ]  // new
})
export class PhotoModule {}

Since this is not obvious I'd like this to be mentioned in the docs, so here is this PR which adds that information to the Techniques/Database page to the end of "Repository pattern" section.

@kamilmysliwiec kamilmysliwiec merged commit db77477 into nestjs:master Sep 4, 2019
duard pushed a commit to duard/docs.nestjs.com that referenced this pull request Apr 4, 2023
content(database) mention exporting repository providers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants