Closed developerasun closed 1 year ago
npm i @nestjs/config dotenv
and import the config module in app.module.ts,
@Module({
imports: [
ConfigModule.forRoot(),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
and then load dotenv module in config file.
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { Quiz } from 'src/modules/quiz/quiz.entity';
import * as dotenv from 'dotenv';
dotenv.config();
export const typeormOptions: TypeOrmModuleOptions = {
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: process.env.POSTGRES_PW,
database: 'quiz',
entities: [Quiz],
synchronize: true, // Setting synchronize: true shouldn't be used in production - otherwise you can lose production data.
autoLoadEntities: true,
};
check if the table is creatd in pg admin.
Describe the bug
To Reproduce Steps to reproduce the behavior:
Expected behavior
DB connected and creating a table automatically
Screenshots
Additional context Add any other context about the problem here.
Labeling Add a proper label for the issue