# Database Integration — नेस्टजेएस

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

> TypeORM या अन्य ORMs के through NestJS को database से connect करें।

## 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 {}
```
