0

I am getting No entity metadata found error for the second database table that i am trying to connect I am trying TypeOrmModule.forRoot to give the details I am able to connect each tables individually by commenting the other. But when I add both, I get entity metadata error for the second entity



import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from './app.controller';
import { AppService } from './app.service';

import { Book } from './entities/book.entity';
import { BookService } from './book/book.service';
import { BooksController } from './books/books.controller';
//import { Entity } from 'typeorm';
import { ConfigModule } from '@nestjs/config';
import { UserController } from './user/user.controller';
import { UserModule } from './user/user.module';
import { UserService } from './user/user.service';
import { User } from './user/entity/user.entity';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal:true
    }),
    TypeOrmModule.forRoot({
      type: 'postgres',
      host:'127.0.0.1',
      port:5432,
      database: 'nestuser',
      username: 'postgres',
      password: 'password',
      entities:[User],
      synchronize: true
    })
    ,
    TypeOrmModule.forRoot({
      type: 'postgres',
      host:'127.0.0.1',
      port:5432,
      database: 'nestngdb',
      username: 'postgres',
      password: 'password',
      //entities: [__dirname + '/**/*.entity{.ts,.js}'],
      entities:[Book],
      synchronize: true,
    }),
    
    TypeOrmModule.forFeature([Book]),
   TypeOrmModule.forFeature([User]),
    
    UserModule
  ],
  controllers: [AppController,BooksController, UserController],
  providers: [AppService, BookService,UserService],
})
export class AppModule {}

0 Answers0