Search⌘ K
AI Features

Quiz on TypeORM

Test your understanding of the NestJS TypeORM library.

We'll cover the following...
Technical Quiz
1.

Which is the correct code for connecting to PostgreSQL with TypeORM?

A.
@Module({
  imports: [
  TypeOrmModule.forRoot({
     type: 'postgres',
     host: 'localhost',
     port: 5432,
     username: 'username',
     password: 'password',
     database: 'test_db',
     entities: [Book, Author],
     synchronize: true,
  })
 ]
})
export class AppModule {}
B.
@Module({
  imports: [
    TypeORM.createConnection({
      type: "postgres",
      host: "localhost",
      port: 5432,
      username: "user",
      password: "password",
      database: "test_db",
    });
  ]
})
export class AppModule {}
C.
@Module({
  imports: [
     TypeORM.initialize({
       postgres: true,
       host: "localhost",
       username: "user",
       password: "password",
       database: "test_db",
    });
  ]
})
export class AppModule {}
D.
@Module({
  imports: [
     TypeORM.setup({
       usePostgres: true,
       hostName: "localhost",
       userId: "user",
       userPassword: "password",
       useDB: "test_db",
     });
  ]
})
export class AppModule {}

1 / 4
...