nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A functionality that enables `forRootAsync()` to initialize database connection in the bootsr

1000ch opened this issue · comments

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

forRootAsync() doesn't ensure DB connection is established during nest bootstrapping because the DB connection will be postponed until it gets the first request if a scope of a logger is Scope.REQUEST.

Describe the solution you'd like

I would like to ensure the situation, DB connection is established during the nest bootstrapping AND the logger is able to capture x-request-ids by having an additional option for forRootAsync() (but please let me know if we already have an existing solution for this).

Teachability, documentation, adoption, migration strategy

N/A

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

Described above.

actually, TypeOrmModule module creates a provider that depends on a database connection as you can see below:

useFactory: async (typeOrmOptions: TypeOrmModuleOptions) => {

thus your app won't be created until you got some connection established (unless you're using the lazy-loading feature)

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.