# Database Integration — NestJS: Scalable Node.js APIs बनाना

Source: https://www.skillbyai.com/hi/nestjs/nestjs-database-integration

> @nestjs/typeorm से NestJS को relational database से जोड़ें और root module में connection configure करें।

## TypeORM setup

`@nestjs/typeorm` और `typeorm` install करें। अपने root module में configure करें।

```bash
npm install @nestjs/typeorm typeorm pg
```

## NestJS में Register करें

Connection को configure करने के लिए `TypeOrmModule.forRoot()` उपयोग करें।

```typescript
import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'localhost',
      port: 5432,
      username: 'user',
      password: 'password',
      database: 'mydb',
      entities: [User, Post],
      synchronize: true
    })
  ]
})
export class AppModule {}
```
