Quiz on TypeORM
Test your understanding of the NestJS TypeORM library.
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 {}
Question 1 of 40 attempted
Get hands-on with 1200+ tech skills courses.