title: How to get a repository or the current TypeORM instance of a NestFastifyApplication object?
body: <p>I am building an API with nest. For E2E tests I am using Jest, in the beforeAll() I instantiate a complete NestJS application using createNestApplication from the AppModule:</p>
  <pre><code>    const module = await Test.createTestingModule({
        imports: [AppModule],
      }).compile();
  
      app = module.createNestApplication&lt;NestFastifyApplication&gt;(
        new FastifyAdapter(),
      );
      await app.init();
  </code></pre>
  <p>Tests and validations are carried out with the app object. For some validations, and to delete records from the database after testing, I am looking for a way to get from the app object the repositories of my entities, or at least, the instance of TypeOrm that has the connection to the database.</p>
  <p><a href="https://nestjs-doc.exceptionfound.com/interfaces/inestapplication.html" rel="nofollow noreferrer">Reviewing the object and its documentation</a> I found that nestJS provides some methods to extract modules, or providers from this object, but I haven't seen anything to extract the DB connection instance. I tried to extract the TypeOrm module using the <a href="https://nestjs-doc.exceptionfound.com/interfaces/inestapplication.html#select" rel="nofollow noreferrer">select method</a> like this:</p>
  <pre><code>    const typeOrmModule = app.select(TypeOrmModule);
  </code></pre>
  <p>But that causes the error:
  Nest could not select the given module (it does not exist in current context)</p>
  <p>I don't want to have to generate a new connection to the DB knowing that the app object already has one. So I wonder if there is a way to extract that instance of the connection or the repositories that the object has inside. Thanks in advance</p>